You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Summary: Addresses the issue in #30109: any mutation of a local in an async function may occur after rendering has finished.
ghstack-source-id: 5cf4b1db7ffff2db962d9b1fc3e9b37e10e3dff2
Pull Request resolved: #30111
// Reassigning a local variable in an async function is *always* mutating
10
+
// after render, so this should error regardless of where this ends up
11
+
// getting called
12
+
value = result;
13
+
});
14
+
};
15
+
16
+
constonClick=async () => {
17
+
awaitreassign();
18
+
};
19
+
return<div onClick={onClick}>Click</div>;
20
+
}
21
+
22
+
```
23
+
24
+
25
+
## Error
26
+
27
+
```
28
+
6 | // after render, so this should error regardless of where this ends up
29
+
7 | // getting called
30
+
> 8 | value = result;
31
+
| ^^^^^ InvalidReact: Reassigning a variable in an async function can cause inconsistent behavior on subsequent renders. Consider using state instead. Variable `value` cannot be reassigned after render (8:8)
Copy file name to clipboardexpand all lines: compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/todo.invalid-reassign-local-variable-in-async-callback.expect.md
0 commit comments