I have a universal react app that\'s using redux and react-router.
I have several routes as follows:
/2016
/2015
/2014
/2013
etc.>
I prefer to have actions dispatched from the render prop itself:
{
this.props.toggleInfoLayer(true);
return ;
}} />
This is assuming you are using Redux's mapDispatchToProps
argument.
I tried using the history change event handler as mentioned in the accepted answer, but I found it undesirable to be dispatching actions from a rogue file. One more place I had to think about, when Redux already provides plenty too many.