1

I have routes defined like following:

<Route path="auth">
   <Route path="confirm-code" component={this.getIndexRoute()} email="xyz@gmail.com" code="1234" />
</Route>

getIndexRoute() gives me a component to navigate to. When I hit http://localhost:3000/de/auth/confirm-code/ it works.

However, I want to modify this path to be like http://localhost:3000/de/auth/confirm-code/email=someEmail&code=someCode I would then want to pass those received email and code as props to my component so that I can process them there. right now I am hard-coding email="xyz@gmail.com" and code=1234. I would like to extract them from the url.

How to do it?

Thinker
  • 5,326
  • 13
  • 61
  • 137

1 Answers1

2

All query params (email, code) are automatically passed to the component via props.location - or depending on which router version you are using you can use withRouter react-router getting this.props.location in child components

Community
  • 1
  • 1
Joe Duncan
  • 366
  • 2
  • 7