RippledComponent warning: Can't call setState (or forceUpdate) on an unmounted component
See original GitHub issueWhen Button is unmounted, React will produce warning as bellow:
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in the componentWillUnmount method.
in RippledComponent (created by App)
Here is minimal test case that would produce warning when button is clicked: https://codesandbox.io/s/9zw5v67kn4
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Can't call setState (or forceUpdate) on an unmounted ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >Prevent React setState on unmounted Component
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >Avoid Memory Leak With React SetState On An Unmounted ...
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application...
Read more >Can't call setState (or forceUpdate) on an unmounted ... - GitHub
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application....
Read more >Prevent React setState on unmounted component - Martin Belev
Warning: Can't call setState (or forceUpdate) on an unmounted component. This is a no-op, but it indicates a memory leak in your application...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think that this is broader issue that would repeat with other components as well in similar situations. From what I understand this is what happens:
When Interacting with material components, they initiate changes to be made by adapter like updating css classes, attributes and styles of component underneath HTML elements as well as requesting value of some attributes and properties. For animation this changes can take some time.
If same interaction makes React component to be unmounted before foundation is over with what it is doing, various warnings/errors could be produced as adapter tries to set state and update/read underneath HTML elements class, styles, attributes.
Adapter methods that manipulate state or update/read underneath HTML elements should probably be shortcircuted when component is unmounted. Maybe it would be great to have this extracted to some util functions so every react component does not have to do same checks over and over again.
@lucasecdb I’ve taken a look at your PR, but I’m suspecting that it is an issue across the board. Similar to what @bmihelac is saying, so I want to investigate before reaching any conclusions. I just haven’t had the time (not ignoring this issue).