Skip to content

Fix for quick unmount and remounts #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhicken
Copy link

@jhicken jhicken commented Apr 13, 2021

I have a case where I am intentionally unmounting and remounting before the debounce gets run in the call stack. And I get errors from react telling me I have a memory leak. This makes that error go away.

I have a case where I am intentionally unmounting and remounting before the debounce gets run in the call stack. And I get errors from react telling me I have a memory leak. This makes that error go away.
const truncatedString = this.getTruncateString(this.props.text)
this.setState({truncatedString, truncating: false})
})
if (this._isMounted) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One other approach here, might be to change debounce to a this.timeoutId = setTimeout(...). When the component unmounts you can just clearTimeout(this.timeoutId) so this function never fires.

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.

3 participants