Skip to content
This repository was archived by the owner on Oct 26, 2018. It is now read-only.

locationBeforeTransitions null initially #483

Closed
andriy-polanski opened this issue Nov 20, 2016 · 1 comment
Closed

locationBeforeTransitions null initially #483

andriy-polanski opened this issue Nov 20, 2016 · 1 comment

Comments

@andriy-polanski
Copy link

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?

@semurgx
Copy link

semurgx commented Nov 21, 2016

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants