mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[tests] failing tests for dependencies and codegen (#1414)
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
let x = foo(props.a?.b.c.d);
|
||||
return x;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
const $ = React.unstable_useMemoCache(2);
|
||||
const c_0 = $[0] !== props.a.b.c.d;
|
||||
let t0;
|
||||
if (c_0) {
|
||||
t0 = foo(props.a?.b?.c?.d);
|
||||
$[0] = props.a.b.c.d;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
const x = t0;
|
||||
return x;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
function Component(props) {
|
||||
let x = foo(props.a?.b.c.d);
|
||||
return x;
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
let a = foo();
|
||||
// freeze `a` so we know the next line cannot mutate it
|
||||
<div>{a}</div>;
|
||||
|
||||
// b should be dependent on `props.a`
|
||||
let b = bar(a[props.a] + 1);
|
||||
return b;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
const $ = React.unstable_useMemoCache(1);
|
||||
const a = foo();
|
||||
let t0;
|
||||
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
||||
t0 = bar(a[props.a] + 1);
|
||||
$[0] = t0;
|
||||
} else {
|
||||
t0 = $[0];
|
||||
}
|
||||
const b = t0;
|
||||
return b;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
function Component(props) {
|
||||
let a = foo();
|
||||
// freeze `a` so we know the next line cannot mutate it
|
||||
<div>{a}</div>;
|
||||
|
||||
// b should be dependent on `props.a`
|
||||
let b = bar(a[props.a] + 1);
|
||||
return b;
|
||||
}
|
||||
Reference in New Issue
Block a user