New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
React 16 : componentDidUpdate Warning: Scheduled a cascading update #834
Comments
It's likely a side effect of how we do subscriptions. But it's nothing to worry about. |
@gontard Did you get any useful info on these warnings ? I got the same |
@Iliyass no. I opened this issue, asked a question on stackoverflow and even chatted about this in the #react-internals chan of reactiflux on discord. But i did not get more details. Since @timdorr said to not worry about this so I did not look further I think it might a new warning of React 16 and in this case a false positive. |
Eh. Really unfortunate that this approach causes people to learn to ignore an otherwise valid and useful warning. Hopefully we can figure out a solution with the new context API soon. :-) |
Okay, after some researching, I fix it in fork, https://github.com/Amareis/react-redux/commit/1303cb5f18d52b5b9509af1420fefa45f6538b94 there is commit. May be i broke something, i dunno, but at least it works as expected. I can made PR if needed. |
A PR would be awesome. |
On the next week I'll improve my solution and will make some PR. |
It means what it says: you scheduled a cascading update. "Cascading" means an update inside an update. React first reconciles the tree by calling |
@Amareis : it would also be helpful if you could put together an example project that demonstrates the behavior, and some benchmarks that compare the behavior before and after, and in React 15 vs React 16. |
@Amareis Keep in mind that the cascading updates was a solution to the problem with connected child components getting newest state before they got new props from their connected parent components. I believe the test for that is |
Ok, I look into this. |
I start my investigation. Seems to this issue don't appears on simple samples, i.e. https://github.com/notrab/create-react-app-redux, need to something more complicated. |
Okay, in my case it behavior was caused by little quick'n'dirty hack - pseudo-selector, which returned data from local storage without any memoization, so objects weren't equals by But I have a simple question. How we can prevent this errors? I bet that @gontard have similar issue it his code, but how he can track this issue without reducing code in search of bad string? For example, why-did-you-update don't complains about this issue (because of new render scheme in react 16, may be?..) |
@Amareis Thanks for your investigation. I thought that it was an issue in react-redux but if it doesn't happen in simple case it might be a problem on my side. Can you give me more details on your "quick'n'dirty hack - pseudo-selector" ? |
@gaearon when you wrote:
Does that means that there is an issue in the connect HOC of |
@gontard it's pretty easy. Something in your |
@Amareis I did not found a similar problem with my selectors. But it seems to be an issue with nested It confirms what @jimbolla said:
|
@liorbrauer do you have the same problem ? I am trying to create a minimal application to reproduce the issue. But i did not succeeded yet. |
I think, this issue is appearing only in really deep nested connected components, and it's related to setState method. May be, if setState can be computed before next animation frame, there is no cascading update, and if we have some fat application, which cannot recompute new state before next frame, it schedules it later? |
@liorbrauer connect HOC is using his own setState method. |
@liorbrauer Do you have any idea? |
To clarify again, the warning is somewhat expected if you use |
So is this the most likely cause of the warning? Or could it be that my code is poorly optimised too? If the second answer is a yes, what would be a good "rule of thumb" to reduce/minimize this warning showing up? To not have |
I had the same issue and I discovered that one of my selectors was always returning a new instance. When I memoized my selector this warning disappeared from the profiler. |
I'm receiving a similar warning but with |
If I get a 1.) Is there any way to find out more details about which lifecycle hook in which component actually scheduled this update? |
@mreishus : per the rest of the discussion in this thread, the warning appears to be due to how React-Redux v5 uses That behavior will be changed in v6. |
I found a case in my application where this error was my fault, and not |
Hi guys, sorry for bringing this issue up. I'd like to ask @gontard if you were able to come up with a minimal app to reproduce this issue because I'm pretty much trying to achieve the same. Also, I'd like to ask @gaearon if it was fixed on |
@eko24ive : Dan doesn't actively maintain Redux or React-Redux any more. We just released React-Redux 6.0, which has a different internal implementation. Please upgrade to that, as I would expect that it resolves this issue. |
Hi @markerikson and thank you for the quick update. |
Hello @markerikson we already updated to React-Redux 6.0 but we still encounter some similar issues. Although we have observed that some warnings are gone. Do you know any possible cause? Or any suggestions on what we can do to know the reason? |
@rauveridgithub : please provide a project that reproduces the issue, preferably as a CodeSandbox. |
Sorry for late update guys. I've upgraded to 6.0 and issue still remains, which confirms my suspicion that |
I profiled the performance of my application using react redux by following this article by Ben Schwarz.
In the user timing section, i get these warnings (with a no entry sign):
There is two messages:
(Committing Changes) Warning: Lifecycle hook scheduled a cascading update
Connect(MyComponent).componentDidUpdate Warning: Scheduled a cascading update
I made some search but i found nothing special. It seems related to the componentDidUpdate function of the
connect
HOC of react-redux.What does these messages means ?
The text was updated successfully, but these errors were encountered: