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.

RippledComponent warning: Can't call setState (or forceUpdate) on an unmounted component

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
bmihelaccommented, Jul 4, 2018

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:

  1. 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.

  2. 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.

1reaction
moog16commented, Jul 6, 2018

@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).

Read more comments on GitHub >

github_iconTop 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 >

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