[compiler] Fixture for non-exhaustive effect deps

ghstack-source-id: 7da27fb09d
Pull Request resolved: https://github.com/facebook/react/pull/31559
This commit is contained in:
Joe Savona
2024-11-15 15:37:27 -08:00
parent 92c0f5f85f
commit 8912702a00
2 changed files with 51 additions and 0 deletions
@@ -0,0 +1,36 @@
## Input
```javascript
import {logValue} from 'shared-runtime';
function Component({a}) {
useEffect(() => {
logValue(a);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 0}],
sequentialRenders: [{a: 1}],
};
```
## Error
```
4 | useEffect(() => {
5 | logValue(a);
> 6 | // eslint-disable-next-line react-hooks/exhaustive-deps
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ InvalidReact: React Compiler has skipped optimizing this component because one or more React ESLint rules were disabled. React Compiler only works when your components follow all the rules of React, disabling them may result in unexpected or incorrect behavior. eslint-disable-next-line react-hooks/exhaustive-deps (6:6)
7 | }, []);
8 | return null;
9 | }
```
@@ -0,0 +1,15 @@
import {logValue} from 'shared-runtime';
function Component({a}) {
useEffect(() => {
logValue(a);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return null;
}
export const FIXTURE_ENTRYPOINT = {
fn: Component,
params: [{a: 0}],
sequentialRenders: [{a: 1}],
};