Reputation: 13
i'm using react-redux-router. I have the following code:
<Router history={hashHistory}>
<Route path="/" component={App}>
<IndexRoute component={Home} />
<Route path="/product/:id" component={Product} />
</Route>
</Router>
I want to show in App component different data when my route is "/" and when my route is "/product/:id". How can I keep track of the change of route in component App.
Upvotes: 1
Views: 636
Reputation: 477
Use react-router-redux
's syncHistory
middleware to keep route in store. Then you can utilize connect
in App component to read pathname from state.routing.location.pathname
and push it to props.
Upvotes: 1