I need to set a dynamic route with query params -> http://localhost:3000/reset-password/?id=2
<Route path="/reset-password/?id=:id" component={ResetPassword} />
But this isn't working and it's showing as page not found. Please help on this.
I need to set a dynamic route with query params -> http://localhost:3000/reset-password/?id=2
<Route path="/reset-password/?id=:id" component={ResetPassword} />
But this isn't working and it's showing as page not found. Please help on this.
?id=:id
, thats part of react-routerexact
keyword;<Route exact path={"/reset-password/:id"} component={ResetPassword} />
Then, in the ResetPassword
component, use the following prop to get the :id
;
this.props.match.params.id
React : difference between <Route exact path="/" /> and <Route path="/" />
Get rid of the query string.
<Route path="/reset-password/:id" component={ResetPassword} />
<Route path="/reset-password" exact render={(props) => <ResetPassword {...props} />} />
<Route path="/reset-password/:id" component={ResetPassword} />
Url to visit: http://localhost:3000/reset-password/2