I have a file with router and a component. Shortly, the code is like this:
// define the routes for each language ..
const InnerRoutes = (
<Route>
<IndexRoute page="home" component={StaticPage}></IndexRoute>
<Route path="contacts" component={ContactsPage}></Route>
<Route path="(:page)" component={StaticPage}></Route>
</Route>
);
// define the routes for all the languages, using InnerRoutes ..
const AllRoutes = (
<Router history={browserHistory}>
<Route path='/' component={App} language="bg">
{InnerRoutes}
<Route path="en" language="en">
{InnerRoutes}
</Route>
</Route>
</Router>
);
// and render our app ..
ReactDOM.render(
AllRoutes,
document.getElementById('app')
);
My question is: how can I have the App
component state changed when router change is triggered?
And of course - have the router params in the app state.
(Because currently I can take the router stuff from the App
component's method componentDidUpdate
and then trigger setState
to change the App
state. Unfortunately - then I have the componentDidUpdate
triggered twice.)