Unmount after drag causes "setState on unmounted component" error
See original GitHub issueDraggable
component seems to trigger an error after it is unmounted as the result of an onStop
handler.
Specifically:
Warning: Can't perform a React state update 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 Draggable (created by App)
It seems similar to #130.
I’ve made a simple repro of the issue with the latest version that you can find here.
It only seems to happen once, and any following unmounts, even on other instances of the component, do not trigger the error.
Issue Analytics
- State:
- Created 5 years ago
- Comments:11
Top Results From Across the Web
Unmount after drag causes "setState on unmounted ... - GitHub
Draggable component seems to trigger an error after it is unmounted as the result of an onStop handler. Specifically: Warning: Can't perform ...
Read more >Can't perform a React state update on an unmounted ...
I am writing an application in React and was unable to avoid a super common pitfall, which is calling setState(...) after componentWillUnmount(.
Read more >Fixing React's “Called SetState() on an ... - How-To Geek
Seeing called setState() on an unmounted component in your browser console means the callback for an async operation is still running after a ......
Read more >Avoid Memory Leak With React SetState On An Unmounted ...
In this post I'll show some possible workarounds for avoiding memory leaks with data fetching.
Read more >ReactJS componentWillUnmount() Method - GeeksforGeeks
The componentWillUnmount() method allows us to execute the React code when the component gets destroyed or unmounted from the DOM (Document ...
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 Free
Top 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
It looks as though you need to
return false
from the onStop handler, and the error is gone - I’ve edited @markvital example with the fix here:https://codesandbox.io/s/epic-kilby-qxzzx?file=/src/index.js
+1 this is annoying