Weird interaction with react-router-redux
See original GitHub issueI found that, when using handleActions
and combineReducers
alongside react-router-redux, the initial state coming out as { routing: [Object] }
Upon investigating further, handleActions
will only return the initialState
if the current state
is undefined
, but react-router-redux is setting it to { routing: [Object] }
react-router-redux triggers a dispatch with { type: '@@router/LOCATION_CHANGE' }
as soon it’s loaded, and it happens before anything else, overwriting the original initialState that was set in handleActions
, I’m having to manually set the initial state with a initialState
action for this purpose.
It seems like a racing condition, but since react-router-redux always calls first, my initial state is always { routing: [Object] }
(which is the state added by react-router-redux).
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top GitHub Comments
after checking the source for redux-actions I noticed that the members of the parameter passed to
handleActions
aren’t exposed. I was expecting that the initialState members would be able to get passed to combineReducers like expected. if it would have it set toObject.defineProperty
with enumerable true, it would work as intended (with the spread operator), like this:I can make a PR for it to work out of the box if it’s interesting, otherwise I’ll just hack my away
If you can accomplish what you can without too much code, I’d just advise doing that. In your case, I guess I’d have a subreducer for
access
, export that, and use the standard convention ofNot sure where you get
router
from, but presumably fromreact-router-redux
.