Skip to content

Conversation

FanchenBao
Copy link
Contributor

I encounter this warning while using the auto scrolling component ("react": "^17.0.1", "react-native": "^0.64.0").

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 a useEffect cleanup function.

It typically means some async function is called after AutoScrolling is unmounted. The culprit points to setIsAutoScrolling inside checkContent. This is understandable as checkContent is called in measureContainerView, which is a callback that can be scheduled to run after component unmount.

The fix is to clean up contentRef, such that checkContent won't be called in measureContainerView upon component unmount.

@minhtc
Copy link
Collaborator

minhtc commented Jul 27, 2021

Thanks for your pull request

@minhtc minhtc merged commit 6cafb3c into homielab:master Jul 27, 2021
@FanchenBao FanchenBao deleted the fanchen/fix_memory_leak branch July 27, 2021 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants