Description
Version
2.0.0
Description
I'm having an issue React Router props.location
being stale after onEnter
changes state during a browser back/forward button press, but not otherwise.
I've already posted on StackOverflow here.
In summary (I'm using Chrome, have not tried other browsers yet):
I have <Route component={MyView} onEnter={enter}>
and enter()
invokes setState()
on MyView
with state based on the new location.
- When route is changed using
browserHistory.pushState()
thenenter()
is invoked andMyView
is rendered withprops.location
as the expected value. This is correct. - When route is changed by browser back/forward button
enter()
is invoked with expected location thenMyView
renders with the oldprops.location
, then renders again a second time with the nextprops.location
. This is a problem becauseMyView
renders with mis-matched data: state has been set based on the new location, but the route shows the old location.
This is a problem because I'm trying to use routes to apply page transitions with ReactCSSTransitionGroup
as shown in the react-router examples, but since the MyView
renders with the new state based on the new position but has the old props.location
it fails to apply the transition before re-rendering the view, then when the second render pass happens it transitions out the new state.
Is this a known issue? Am I doing something wrong?