mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Repro for inconsistent context/local variable reference
We currently assume JSX element tags are always locals, and need to check which load kind to use. Fixed in the next PR.
This commit is contained in:
+29
@@ -0,0 +1,29 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
let Component = Foo;
|
||||
|
||||
Component = useMemo(() => {
|
||||
return Component;
|
||||
});
|
||||
|
||||
return <Component />;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
6 | });
|
||||
7 |
|
||||
> 8 | return <Component />;
|
||||
| ^^^^^^^^^ [ReactForget] Invariant: Expected all references to a variable to be consistently local or context references. Identifier <unknown> Component$2 is referenced as a local variable, but was previously referenced as a context variable (8:8)
|
||||
9 | }
|
||||
10 |
|
||||
```
|
||||
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function Component(props) {
|
||||
let Component = Foo;
|
||||
|
||||
Component = useMemo(() => {
|
||||
return Component;
|
||||
});
|
||||
|
||||
return <Component />;
|
||||
}
|
||||
Reference in New Issue
Block a user