Assuming I have a code like this:
<Router history={history}>
<Route path="/users/(:userId)" component={UserContainer}>
<Route path="profile" component={UserProfileContainer} />
<Route path="stats" component={UserStatsContainer}>
<IndexRoute component={UserDashboard} />
</Route>
</Router>
In the UserContainer, I have something like this:
const {userId} = this.props.params;
return (
<div>
{this.props.children}
</div>
);
How can I pass the userId to the child components (UserProfileContainer, UserStatsContainer, etc) defined in the router config?
Those components need to know the current userId as well.
Thanks.
u can get it just like u did in 'UserContainer' : 'const {userId} = this.props.params;'....... : )