Component no longer updating with react-redux 6.0.0
See original GitHub issueDo you want to request a feature or report a bug?
Bug
What is the current behavior?
The current behavior is that my react component is not getting updated after I update the redux store. In fact, mapStateToProps is not getting called except for the initial mount.
Here is a fairly minimal repo I set up that reproduces the issue: https://github.com/mjhoffm2/react-demo/tree/react-redux-bug-demo/node
In this demo, the ChannelList
component dispatches a LOAD_CHANNELS
action when it mounts, which updates channels
in the redux store. However, mapStateToProps
doesn’t get called a second time. I need to force my component to remount by changing the key from the parent to see the updated data.
What is the expected behavior?
The expected behavior is that my component will be updated when the redux store is updated. This works as intended if I switch to using react-redux 5.1.1, but does not work when I use version 6.0.0. Even if I call this.forceUpdate();
in my component, it does not get the new data from the redux store.
Which versions of Redux, and which browser and OS are affected by this issue? Did this work in previous versions of Redux?
I am using Redux 4.0.0 and Google Chrome. I have not tested previous versions of Redux, but this has worked with previous versions of React-Redux.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:10 (4 by maintainers)
Top GitHub Comments
Huh. I’m looking at this, and I’m pretty confused.
Provider
is clearly detecting that the state changed between first render and mount, and callingthis.setState({storeState : postMountStoreState})
. It then re-renders.But… the context consumer render callbacks in the connected components aren’t firing at all when that re-render happens.
checking…
AHA!
You have mismatched versions of
react
andreact-dom
. You’re usingreact@16.6.3
, butreact-dom@16.5
.If I update both to
react@latest react-dom@latest
, then it works correctly.ALWAYS KEEP YOUR REACT VERSIONS IN SYNC! Bad things will happen if you don’t 😃
Hmm. Code seems reasonable at first glance. I’ll try to take a look at this over the next day or two.