mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Repro for destructuring with partial context variables
This commit is contained in:
+35
@@ -0,0 +1,35 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
import { useMemo } from "react";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
function Component({}) {
|
||||
let a = "a";
|
||||
let b = "";
|
||||
[a, b] = [null, null];
|
||||
return <Stringify a={a} b={b} onClick={() => a} />;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{}],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
5 | let a = "a";
|
||||
6 | let b = "";
|
||||
> 7 | [a, b] = [null, null];
|
||||
| ^ [ReactForget] Invariant: Expected consistent kind for destructuring. Other places were 'Const' but 'store b$36[10:12]' is reassigned (7:7)
|
||||
8 | return <Stringify a={a} b={b} onClick={() => a} />;
|
||||
9 | }
|
||||
10 |
|
||||
```
|
||||
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { useMemo } from "react";
|
||||
import { Stringify } from "shared-runtime";
|
||||
|
||||
function Component({}) {
|
||||
let a = "a";
|
||||
let b = "";
|
||||
[a, b] = [null, null];
|
||||
return <Stringify a={a} b={b} onClick={() => a} />;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [{}],
|
||||
};
|
||||
Reference in New Issue
Block a user