Skip to content

fix(fixture): correct variable name in componentWillUnmount#706

Open
everettbu wants to merge 1 commit into
mainfrom
fix/attribute-behavior-memory-leak
Open

fix(fixture): correct variable name in componentWillUnmount#706
everettbu wants to merge 1 commit into
mainfrom
fix/attribute-behavior-memory-leak

Conversation

@everettbu
Copy link
Copy Markdown

Mirror of facebook/react#36030
Original author: MorikawaSouma


Summary

In \ ixtures/attribute-behavior/src/App.js, the \componentWillUnmount\ method had a bug where it checked for \ his.timeout\ but cleared \ his.interval\ (which doesn't exist).

This caused a memory leak where timeouts were never properly cleaned up on component unmount.

Fix

Changed:
\\js
clearTimeout(this.interval);
\\

To:
\\js
clearTimeout(this.timeout);
\\

Test Plan

  • No functional changes, only a bug fix in fixture code
  • Verify the correct variable is now being cleared

Fixes #35814

The clearTimeout was using this.interval instead of this.timeout,
causing a memory leak where timeouts were never properly cleaned up.

Fixes #35814
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Mar 13, 2026

Greptile Summary

This PR fixes a one-line bug in the componentWillUnmount method of the Result class in fixtures/attribute-behavior/src/App.js, where clearTimeout(this.interval) was incorrectly called instead of clearTimeout(this.timeout).

  • The Result component uses only this.timeout (set via setTimeout in onMouseEnter) — there is no this.interval property anywhere in the class.
  • The pre-fix code was effectively a no-op on unmount (clearTimeout(undefined) does nothing), meaning any pending timeout would survive component unmount, causing a memory leak.
  • Both onMouseEnter and onMouseLeave already correctly referenced this.timeout; this change makes componentWillUnmount consistent with those handlers.
  • The fix is confined to fixture/demo code, so there is no impact on the React library itself.

Confidence Score: 5/5

  • This PR is safe to merge — it is a single-line, clearly correct bug fix in fixture code with no risk of regression.
  • The change is minimal and self-evidently correct: the rest of the class consistently uses this.timeout, and this.interval does not exist. The fix aligns componentWillUnmount with the established pattern and resolves a real memory-leak path in a fixture file.
  • No files require special attention.

Important Files Changed

Filename Overview
fixtures/attribute-behavior/src/App.js Corrects componentWillUnmount to call clearTimeout(this.timeout) instead of clearTimeout(this.interval), fixing a memory leak where the pending timeout was never cleared on unmount.

Last reviewed commit: f2e7294

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.

2 participants