question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Component no longer updating with react-redux 6.0.0

See original GitHub issue

Do 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:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
markeriksoncommented, Dec 14, 2018

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 calling this.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 and react-dom. You’re using react@16.6.3, but react-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 😃

2reactions
markeriksoncommented, Dec 13, 2018

Hmm. Code seems reasonable at first glance. I’ll try to take a look at this over the next day or two.

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - React component not updating on final dispatch and ...
I am fairly new to React and Redux and I have an issue with my component not updating on the final dispatch that...
Read more >
Upgrading to React-Redux v6: Around the New Context API
So React-Redux upgraded to 6.0.0. I've spent some time to migrate our ... In v6, React-Redux no longer uses React's Legacy Context API....
Read more >
Troubleshooting | React Navigation
Sometimes you might have noticed that your screens unmount/remount, or your local component state or the navigation state resets when you navigate. This...
Read more >
React v18.0 – React Blog
React 18 is now available on npm! In our last post, we shared step-by-step instructions for upgrading your app to React 18.
Read more >
react-redux - npm
Official React bindings for Redux. Latest version: 8.0.5, last published: 2 months ago. Start using react-redux in your project by running ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found