Description
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-compiler (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/guillaumebrunerie/react-compiler-bug
Repro steps
- Start the linked repro with
npm run dev
. - Hover the text, and note that the hover text appears to the right.
- Uncomment the
"use no memo"
directive insrc/App.tsx
and notice that the hover text now appears below.
There are no lint errors, but the compiler causes the component to behave differently, so I guess it’s a bug in the compiler?
I noticed this issue when setting up the React compiler in one of my projects, and noticed that some components started behaving incorrectly. It is custom code that implements anchor-like positioning in JS, so somewhat messy code with refs, layout effects, and calculating the size and position of DOM elements. Suddenly one on the popups ended up positioned at (0, 0)
with the compiler active, and adding "use no memo"
in the affected component made the issue go away.
The repro here is a simplified version, which still behaves differently with and without the compiler. I am not aware of breaking any rules of React, but it is very possible I’m hitting some undefined behavior in the order in which effects run or similar.
I couldn’t simplify it much further, in particular
- removing
useHover
to always returntrue
makes the issue go away, - replacing the
refContainer
by the ref itself makes the issue go away, - removing
hoverRef
makes the issue go away.
How often does this bug happen?
Every time
What version of React are you using?
19.1.0
What version of React Compiler are you using?
19.1.0-rc.1