react-router-redux icon indicating copy to clipboard operation
react-router-redux copied to clipboard

locationBeforeTransitions null initially

Open andriy-polanski opened this issue 10 years ago • 1 comments

I am writing an isomorphic app with react and using react-router-redux. I am doing following to sync store with browserHistory on client rendering, but on initial load, locationBeforeTransitions is null.

const history = syncHistoryWithStore(browserHistory, store);

...
<Router routes={ routes } history={ history } />

Should I fire LOCATION_CHANGE on server side manually to populate initial locationBeforeTransitions?

andriy-polanski avatar Nov 20 '16 18:11 andriy-polanski

https://github.com/reactjs/react-router-redux#how-do-i-access-router-state-in-a-container-component

You should not read the location state directly from the Redux store. This is because React Router operates asynchronously (to handle things such as dynamically-loaded components) and your component tree may not yet be updated in sync with your Redux state. You should rely on the props passed by React Router, as they are only updated after it has processed all asynchronous code.

semurgx avatar Nov 21 '16 12:11 semurgx