mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Repro for multiple declarations in for initializer codegen issue
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
const items = [];
|
||||
|
||||
for (let i = 0, length = props.items.length; i < length; i++) {
|
||||
items.push(props.items[i]);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
let items;
|
||||
if ($[0] !== props.items) {
|
||||
items = [];
|
||||
for (let i = 0; i < length; i++) {
|
||||
items.push(props.items[i]);
|
||||
}
|
||||
$[0] = props.items;
|
||||
$[1] = items;
|
||||
} else {
|
||||
items = $[1];
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
function Component(props) {
|
||||
const items = [];
|
||||
|
||||
for (let i = 0, length = props.items.length; i < length; i++) {
|
||||
items.push(props.items[i]);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -535,6 +535,7 @@ const skipFilter = new Set([
|
||||
"bug-jsx-memberexpr-tag-in-lambda",
|
||||
"bug-invalid-code-when-bailout",
|
||||
"component-syntax-ref-gating.flow",
|
||||
"for-multiple-variable-declarations-in-initializer",
|
||||
|
||||
// 'react-forget-runtime' not yet supported
|
||||
"flag-enable-emit-hook-guards",
|
||||
|
||||
Reference in New Issue
Block a user