score:0

So you have to wrap your main application component in a withRouter and react based on props changing in the props that withRouter passes down, namely the props.location.pathname for example.

You can see a discussion of how it may work here https://github.com/ReactTraining/react-router/issues/4603

score:2

Seems like the best way to dispatch an action is to do so at component's componentWillMount(), componentDidMount() or componentWillUnmount() methods.

IGNORE WHATS BELOW

There is onEnter prop. Like here comet-frontend

onEnter(nextState, replace, callback?)

Called when a route is about to be entered. It provides the next router state and a function to redirect to another path. this will be the route instance that triggered the hook. https://github.com/ReactTraining/react-router/blob/master/docs/API.md#onenternextstate-replace-callback

BUT, there still is onChange prop, doing exactly what you described. Maybe tell us what exactly is your issue. Because seems like you're doing something wrong.


Related Query

More Query from same tag