fix: properly remove event listeners in component unmount to prevent memory leaks#35670
fix: properly remove event listeners in component unmount to prevent memory leaks#35670ZIRUL-0902 wants to merge 2 commits intofacebook:mainfrom
Conversation
…ls in component unmount. All event listeners are now properly cleaned up.
|
Hi @ZIRUL-0902! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
There was a problem hiding this comment.
Pull request overview
This PR addresses memory leaks in a React concurrent rendering fixture by adding proper cleanup of event listeners in the component unmount lifecycle. However, the PR inadvertently removes critical application initialization code and misses cleanup for a debounced function.
Changes:
- Added
componentWillUnmountlifecycle method with event listener cleanup - Refactored keydown event handler to be a class property for proper removal
- Applied formatting changes to setState calls and object destructuring
- Removed application initialization code at the end of the file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </div> | ||
| <input | ||
| className={'input ' + this.state.strategy} | ||
| className={"input " + this.state.strategy} |
There was a problem hiding this comment.
The quote style has been changed from single quotes to double quotes, which is inconsistent with the rest of the codebase. The file and related files in this fixture consistently use single quotes for string literals. This should use single quotes for consistency with the codebase convention.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </div> | ||
| <input | ||
| className={'input ' + this.state.strategy} | ||
| className={"input " + this.state.strategy} |
There was a problem hiding this comment.
Inconsistent quote style: double quotes are used here while the rest of the codebase consistently uses single quotes for string literals. For example, Charts.js line 19 and other parts of this file use single quotes.
This PR fixes a memory leak caused by missing removeEventListener calls in component unmount. All event listeners are now properly cleaned up.