Skip to content

fix: properly remove event listeners in component unmount to prevent memory leaks#35670

Open
ZIRUL-0902 wants to merge 2 commits intofacebook:mainfrom
ZIRUL-0902:main
Open

fix: properly remove event listeners in component unmount to prevent memory leaks#35670
ZIRUL-0902 wants to merge 2 commits intofacebook:mainfrom
ZIRUL-0902:main

Conversation

@ZIRUL-0902
Copy link

This PR fixes a memory leak caused by missing removeEventListener calls in component unmount. All event listeners are now properly cleaned up.

…ls in component unmount. All event listeners are now properly cleaned up.
Copilot AI review requested due to automatic review settings February 2, 2026 08:07
@meta-cla
Copy link

meta-cla bot commented Feb 2, 2026

Hi @ZIRUL-0902!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 componentWillUnmount lifecycle 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}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

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 uses AI. Check for mistakes.
@ZIRUL-0902
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

@ZIRUL-0902 ZIRUL-0902 marked this pull request as draft February 2, 2026 08:20
@meta-cla
Copy link

meta-cla bot commented Feb 2, 2026

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla bot added the CLA Signed label Feb 2, 2026
@ZIRUL-0902 ZIRUL-0902 closed this Feb 2, 2026
@ZIRUL-0902 ZIRUL-0902 reopened this Feb 2, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@ZIRUL-0902 ZIRUL-0902 requested a review from Copilot February 2, 2026 08:26
@ZIRUL-0902 ZIRUL-0902 marked this pull request as ready for review February 2, 2026 08:27
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

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}
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

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.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant