Reputation: 4821
I'm using react router on a project and when I'm using the Link
tag I'm not getting this.props.params
properly filled when reading it on the new Page.
<Link to='/users/login/' params={{firstParam: 'firstParam'}} query={{firstParam: 'firstParam'}}>link</Link>
Anyone knows why it could be?
EDIT: I've also tried doing it this way
this.refs.linkToLogin.context.router.transitionTo('/users/login', {firstParam: 'firstParam'});
EDIT2: The route is defined this way
<Route name="users">
...
<Route name="users-login" path="/users/login" handler={UserPage} />
...
</Route>
Upvotes: 0
Views: 87
Reputation: 4820
Your link is set up correctly, I expect its an issue with your route handler. it must be configured to accept the state
argument from the callback function. your routes file should look like this:
Router.run(routes, function(Handler, state){
React.render(<Handler {...state} />, document.querySelector('#foo')
})
the important thing to note here is the state
argument in the callback function getting passed to the Handler
component
additionally, your route needs to be configured to accept a dynamic param. The #props.query
should go through correctly, but unless a dynamic segment of the url is defined, the params
likely wont show up
<Route name='...' path='/users/:firstParam/login' handler={UserPage} />
Upvotes: 1