-
Notifications
You must be signed in to change notification settings - Fork 49.6k
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
Repro steps
Open the repro link, the error will be on the side
Found 1 error:
Error: Cannot access variable before it is declared
repeatEvent
is accessed before it is declared, which prevents the earlier access from updating when this value changes over time.
4 | props.onRepeat();
5 | setTimeout(() => {
6 | repeatEvent();
| ^^^^^^^^^^^repeatEvent
accessed before it is declared
7 | }, 60);
8 | });
9 |
1 |
2 | function TimerBasedComponent(props) {
3 | const repeatEvent = useEffectEvent(() => {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 | props.onRepeat();
| ^^^^^^^^^^^^^^^^^^^^^
5 | setTimeout(() => {
| ^^^^^^^^^^^^^^^^^^^^^
6 | repeatEvent();
| ^^^^^^^^^^^^^^^^^^^^^
7 | }, 60);
| ^^^^^^^^^^^^^^^^^^^^^
8 | });
| ^^^^^^repeatEvent
is declared here
9 |
10 | let [down, setDown] = useState(false);
11 | useEffect(() => {
How often does this bug happen?
Every time
What version of React are you using?
19.2
What version of React Compiler are you using?
7.0.0