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.

Unmount after drag causes "setState on unmounted component" error

See original GitHub issue

Draggable 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:closed
  • Created 5 years ago
  • Comments:11

github_iconTop GitHub Comments

8reactions
jsguycommented, May 4, 2020

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

4reactions
timoxleycommented, Aug 14, 2019

+1 this is annoying

Read more comments on GitHub >

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

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