I started getting a Maximum call stack size exceeded error after adding some code to dispatch actions via onEnter hooks in react-router. I had used the code in the README to link up redux-immutable and react-router-redux.
It turns out that react-router-redux performs a strict equality check on the location object. The example in this repository merges the data directly into the store, which causes said object to be converted into an Immutable data structure. The strict equality check will fail once it is converted back to JS, making react-router-redux think the location has changed. Such change will lead to the onEnter hook being run again, and so on.
The proposed change modifies the code to explicitly set the "locationBeforeTransitions" key to the action's payload, which will preserve it as a plain object.
It also changes toJS() to toObject() in selectLocationState(). This provides no real practical difference, but has the advantage of being less ambiguous about what data will be returned, because anything beyond the top-level map is returned verbatim.
I started getting a
Maximum call stack size exceeded
error after adding some code to dispatch actions viaonEnter
hooks in react-router. I had used the code in the README to link up redux-immutable and react-router-redux.It turns out that react-router-redux performs a strict equality check on the location object. The example in this repository merges the data directly into the store, which causes said object to be converted into an Immutable data structure. The strict equality check will fail once it is converted back to JS, making react-router-redux think the location has changed. Such change will lead to the
onEnter
hook being run again, and so on.The proposed change modifies the code to explicitly set the "locationBeforeTransitions" key to the action's payload, which will preserve it as a plain object.
It also changes
toJS()
totoObject()
inselectLocationState()
. This provides no real practical difference, but has the advantage of being less ambiguous about what data will be returned, because anything beyond the top-level map is returned verbatim.