Skip to content
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

Merged
merged 5 commits into from
Jun 21, 2018
Merged

Fix memory leak warning (#476) #479

merged 5 commits into from
Jun 21, 2018

Conversation

alexandernanberg
Copy link
Collaborator

@alexandernanberg alexandernanberg commented Jun 21, 2018

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:

  • Documentation (Don't think any new documentation is needed)
  • Tests
  • Ready to be merged
  • Added myself to contributors table

@alexandernanberg
Copy link
Collaborator Author

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 😄

@alexandernanberg alexandernanberg changed the title Fix memory leak warning. fixes #476 Fix memory leak warning (#476) Jun 21, 2018
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

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

Super, thanks!

@kentcdodds kentcdodds merged commit e762248 into downshift-js:master Jun 21, 2018
@kentcdodds
Copy link
Member

Thanks so much for your help! I've added you as a collaborator on the project. Please make sure that you review the other/MAINTAINING.md and CONTRIBUTING.md files (specifically the bit about the commit messages and the git hooks) and familiarize yourself with the code of conduct (we're using the contributor covenant). You might also want to watch the repo to be notified when someone files an issue/PR. Please continue to make PRs as you feel the need (you can make your branches directly on the repo rather than your fork if you want). Thanks! And welcome to the team :)

@kentcdodds
Copy link
Member

🎉 This PR is included in version 2.0.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@alexandernanberg alexandernanberg deleted the fix/memory-leak-warning branch June 28, 2018 07:33
Rendez pushed a commit to Rendez/downshift that referenced this pull request Sep 30, 2018
* 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
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.

memory leak warning
2 participants