mirror of
https://github.com/facebook/react.git
synced 2026-11-18 20:15:56 +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:
1 parent
0e72e2a00e
commit
21bb8f9e75
2 files changed
+38
No files matched your search
+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