#36128·React

[Compiler Bug]: React Compiler bug: closure is lost in `useEffect` when component is returned from a factory (causes `ReferenceError: <identifier> is not defined`)

Author: budarinCreated Mar 23, 2026Updated Oct 1, 2026
LabelsType: BugStatus: Unconfirmed

What kind of issue is this?

  • React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
  • babel-plugin-react-compiler (build issue installing or using the Babel plugin)
  • eslint-plugin-react-hooks (build issue installing or using the eslint plugin)
  • react-compiler-healthcheck (build issue installing or using the healthcheck script)

Link to repro

https://github.com/budarin/react-compiler-bug-repro

Repro steps

  1. Create a Vite React TS project with React Compiler enabled.
  2. Use a factory function that returns a component and captures injected dependencies (e.g. showWelcomeNotification) in a closure.
  3. Inside the returned component, call the injected dependency in a useEffect.
  4. Run the dev server; a runtime ReferenceError occurs.

How often does this bug happen?

Every time

What version of React are you using?

19.2.4

What version of React Compiler are you using?

1.0.0