React-router: this.props.location.state is undefined

Created on 3 Jan 2020  路  3Comments  路  Source: ReactTraining/react-router

Im trying to pass parameters through Redirect component, but i get this.props.location.state as undefined. What should i do?

Most helpful comment

Having the same issue on 5.1.2

Protected Route component:

return <Redirect
            to={{
              pathname: '/auth/login',
              state: { from: props.location },
            }}
          />

Login Component:

props.location.state // is undefined

All 3 comments

Those will be on this.props.match.params.

params also gets undefined

Having the same issue on 5.1.2

Protected Route component:

return <Redirect
            to={{
              pathname: '/auth/login',
              state: { from: props.location },
            }}
          />

Login Component:

props.location.state // is undefined
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ArthurRougier picture ArthurRougier  路  3Comments

jzimmek picture jzimmek  路  3Comments

alexyaseen picture alexyaseen  路  3Comments

wzup picture wzup  路  3Comments

misterwilliam picture misterwilliam  路  3Comments