monkeydeveloper monkeydeveloper - 3 months ago 15
React JSX Question

react-router: How to get parameter value from URL

How can I define a route in my routes.jsx file to capture the __firebase_request_key parameter value from an URL generated by twitter single sign on process after the redirect from their servers?

http://localhost:8000/#/signin?_k=v9ifuf&__firebase_request_key=blablabla


I tried with the following routes configuration but the :redirectParam is not catching the mentioned param:

<Router>
<Route path="/" component={Main}>
<Route path="signin" component={SignIn}>
<Route path=":redirectParam" component={TwitterSsoButton} />
</Route>
</Route>
</Router>


Thanks.

Answer

React Router already parses the location for you. You can access it via

this.props.location.query.yourParamName

nizam.sp's suggestion to do

console.dir(this.props)

will be helpful in any case.