mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[compiler] Fix broken fire snapshot (#31920)
This was not committed in #31811 --- [//]: # (BEGIN SAPLING FOOTER) Stack created with [Sapling](https://sapling-scm.com). Best reviewed with [ReviewStack](https://reviewstack.dev/facebook/react/pull/31920). * #31919 * #31918 * #31917 * #31916 * #31915 * __->__ #31920
This commit is contained in:
+13
-10
@@ -12,9 +12,12 @@ function Component(props) {
|
||||
|
||||
const deps = [foo, props];
|
||||
|
||||
useEffect(() => {
|
||||
fire(foo(props));
|
||||
}, ...deps);
|
||||
useEffect(
|
||||
() => {
|
||||
fire(foo(props));
|
||||
},
|
||||
...deps
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -25,13 +28,13 @@ function Component(props) {
|
||||
## Error
|
||||
|
||||
```
|
||||
11 | useEffect(() => {
|
||||
12 | fire(foo(props));
|
||||
> 13 | }, ...deps);
|
||||
| ^^^^ Invariant: Cannot compile `fire`. You must use an array literal for an effect dependency array when that effect uses `fire()` (13:13)
|
||||
14 |
|
||||
15 | return null;
|
||||
16 | }
|
||||
13 | fire(foo(props));
|
||||
14 | },
|
||||
> 15 | ...deps
|
||||
| ^^^^ Invariant: Cannot compile `fire`. You must use an array literal for an effect dependency array when that effect uses `fire()` (15:15)
|
||||
16 | );
|
||||
17 |
|
||||
18 | return null;
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user