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.


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


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