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:
Joe Savona
2024-03-21 17:12:08 -07:00
parent 0e72e2a00e
commit 21bb8f9e75
2 changed files with 38 additions and 0 deletions
@@ -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 |
```
@@ -0,0 +1,9 @@
function Component(props) {
let Component = Foo;
Component = useMemo(() => {
return Component;
});
return <Component />;
}