I am testing v5 alpha from #416 and noticed that after some time every re-render in one of my components starts triggering following warning:
Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code
My best guess is that there is a memory leak somewhere and new connect holds a reference to unmounted component. Triple checked that it doesn't happen with 4.4.5.
It doesn't happen right away, only after I switch back and forth between routes that re-render a lot of components. I don't have time to dig deeper and set up a test project, but I can create a branch in my public repo where it's happening to reproduce. Please let me know if you want this.
I have the same issue
A repro would be very helpful. Thanks.
@max-mykhailenko do you have simple steps to repro?
@Restuta Do you have a reproducible test case as well?
Does this occur in the canonical real-world example? https://github.com/reactjs/redux/tree/master/examples/real-world
@timdorr not it does not, I created a branch that you can use to repro it.
Branch: https://github.com/Restuta/rcn.io/tree/react-redux-connect-bug
Steps to repro:
git clone [email protected]:Restuta/rcn.io.gitrcn.ionpm i && npm run devYou should see in console:
"Warning: setState(...): Can only update a mounted or mounting component. This usually means you called setState() on an unmounted component. This is a no-op. Please check the code for the Connect(EventDetails) component."
Notice that the only change from "dev" branch is bump of redux-react and you can test it yourself that issue is not happening with 4.4.5. @jimbolla
Thanks, I'll have a look at this tonight.
@Restuta That git repo address doesn't seem to work for me. Is it supposed to be https://github.com/Restuta/rcn.io.git?
@jimbolla that address is in SSH format, of you prefer HTTPS then yes, use that one
I have a fix ready for this here but I'm going to attempt to write a test for it before submitting the PR. Honestly, writing the test is the hard part for me. :laughing:
@jimbolla what do you think the timeline is for getting this in? This is the last thing before #465 gets in, which is causing some UI issues for our beta users so I'm more than happy to write some tests if you're feeling tied up. :-)
@vhmth Unfortunately I have commitments this weekend, so I won't be able to work on it again until Monday evening. I have off Tuesday and plan to work on it then as well.
I started writing a test but am having difficulty reproducing the behavior from scratch. I'm going to take a different approach and start with @Restuta's project and just start ripping out all the unrelated code until I'm left with the minimum code that reproduces the error. Then I'll turn that into a test.
Sounds like a plan @jimbolla. If I have some time later on Sunday, I'll see if I can repro too. Maybe that will save ya some time and you could turn that into a test if I come up with that minimal example.
That sounds like it would be very helpful. Thanks. :smile:
Don't hesitate to send a PR with minimal repro setup for the branch I created @vhmh
Hey guys I'm sorry about the push off. A lot of stuff landed on my plate (life stuff) this weekend and couldn't get to working on repro-ing that bug. I will try tomorrow afternoon. I know @jimbolla said he wouldn't be able to get to it until tomorrow too, but it may be good to have two set of eyes on trying to repro it.
New PR #472 with fix and test is ready.
Fixed in #472. I'll push out a beta release tonight.
react-redux-5.0.0-beta.1 has been published to react-router@next!
on it, testing
Thanks, Tim!
looking good so far, thanks guys!
Been using it in our staging extension and things are looking good. Will be rolling out our extension using this with our 150-ish beta users and let y'all know if we run into any issues.
Most helpful comment
react-redux-5.0.0-beta.1has been published toreact-router@next!