score:32

Accepted answer

You can use the location prop to access the state you have passed. Visit React-Router for reference. When you want to access that state, you can do it by this.props.location.state.

score:1

you can access state using this.props.location.state

score:10

If you're using React hooks you can use useLocation hook.

import { useLocation } from 'react-router-dom';

export const MyComponent = () => {
  const { state } = useLocation();

  ...
} 

Related Query

More Query from same tag