facebook / react · Issue No. 37194
https://github.com/Aryan4123/react-compiler-jest-mock-repro/pull/1
Check out PR: https://github.com/Aryan4123/react-compiler-jest-mock-repro/pull/1
Run npm install.
Run npm test.
Jest fails during Babel transformation with:
The module factory of jest.mock() is not allowed to reference any out-of-scope variables.Invalid variable access: _c
The mock factory declares an inline JSX component. React Compiler transforms that component and references its generated module cache helper _c from inside the factory. Jest's hoist transform rejects _c as an out-of-scope variable before the test executes.
Expected: the test should transform and execute successfully.
Controls:
npm run test:no-compiler passes with the same test and React Compiler disabled.npm run test:workaround passes with React Compiler enabled and a file-level 'use no memo' directive.Every time
19.2.4
1.0.0
Relay reads this issue against the repository's contribution signals: the files it is likely to touch, how the maintainers triage work this size, and what the first contribution would exercise.
The full analysis for this issue is still being assembled. Until then, the description above and the thread on GitHub are the most reliable context.