handleResize should not call setState when unmounted
See original GitHub issueI’m getting this console warning:
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 %s.%sthe componentWillUnmount method
in ImageGallery (created by Context.Consumer)
Tracked it down to the handleResize
method calling setState
.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Prevent React setState on unmounted Component
It usually means you have called setState on an unmounted component . ... not calling setState on unmounted components should show up too....
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 on an unmounted component
As a note, don't call async/await functions in the constructor. The constructor should initialize the component and return it as soon as ...
Read more >Fixing React's “Called SetState() on an ... - How-To Geek
Seeing Called setState() on an Unmounted Component in your console is one of the most frequent issues faced by newcomers to React.
Read more >Avoid React state update warnings on unmounted components
React raising a warning when you try to perform a state update on an unmounted component. React setState is used to update the...
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
Hi, just to confirm, I have encountered the same issue. Cheers!
This bug appears when the gallery has just loaded and is unmounted
To reproduce it navigate to a page with gallery, and quickly push back button.
Not easy to reproduce but I am using your gallery for a school project. No error tolerated in the console.
Easy fix
In any case, well done for this component. Almost perfect ! Best react gallery.