-
Notifications
You must be signed in to change notification settings - Fork 933
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
Fix memory leak warning (#476) #479
Fix memory leak warning (#476) #479
Conversation
I've now added tests for this as well. I've not worked a lot with either Jest or react-testing-library so if there is anything that you want me to edit please tell me and I'll try to fix it 😄 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super, thanks!
Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the |
🎉 This PR is included in version 2.0.7 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
* Prevent setState on unMounted components * Update contributor * Return undefined to fix eslint errors * Fix spelling in comment * Add tests for setting state on an unmounted component
What:
Don't run setState on unmounted components. Fixes #476
Why:
To prevent a possible memory leak plus removing a warning being emitted in the console from React.
How:
In #476 you proposed two different solutions for this and I decided to go for the solution with the
_isMounted
flag. That flag was already used for other things so it felt natural to just go with that solutions for this as well. Although I still think that clearing the timeouts is a better and more robust overall solution for the problem, so it might be worth revisiting this later.I'm unsure if you would like me to add tests for this? If you would like that, I'd like some guidance on how you would like that to be implemented.Checklist: