mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
More fixtures for reactivity and mutable aliasing (property load case)
This commit is contained in:
+87
@@ -0,0 +1,87 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function Component(props) {
|
||||
const x = {};
|
||||
const y = [];
|
||||
x.y = y;
|
||||
x.y.push(props.input);
|
||||
|
||||
let z = 0;
|
||||
if (x.y[0]) {
|
||||
z = 1;
|
||||
}
|
||||
|
||||
return [z];
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
sequentialRenders: [
|
||||
{ input: true },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
## Code
|
||||
|
||||
```javascript
|
||||
import { unstable_useMemoCache as useMemoCache } from "react";
|
||||
function Component(props) {
|
||||
const $ = useMemoCache(2);
|
||||
const x = {};
|
||||
const y = [];
|
||||
x.y = y;
|
||||
x.y.push(props.input);
|
||||
|
||||
let z = 0;
|
||||
if (x.y[0]) {
|
||||
z = 1;
|
||||
}
|
||||
let t0;
|
||||
if ($[0] !== z) {
|
||||
t0 = [z];
|
||||
$[0] = z;
|
||||
$[1] = t0;
|
||||
} else {
|
||||
t0 = $[1];
|
||||
}
|
||||
return t0;
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
sequentialRenders: [
|
||||
{ input: true },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
],
|
||||
};
|
||||
|
||||
```
|
||||
|
||||
### Eval output
|
||||
(kind: ok) [1]
|
||||
[1]
|
||||
[0]
|
||||
[0]
|
||||
[1]
|
||||
[0]
|
||||
[1]
|
||||
[0]
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
function Component(props) {
|
||||
const x = {};
|
||||
const y = [];
|
||||
x.y = y;
|
||||
x.y.push(props.input);
|
||||
|
||||
let z = 0;
|
||||
if (x.y[0]) {
|
||||
z = 1;
|
||||
}
|
||||
|
||||
return [z];
|
||||
}
|
||||
|
||||
export const FIXTURE_ENTRYPOINT = {
|
||||
fn: Component,
|
||||
params: [],
|
||||
sequentialRenders: [
|
||||
{ input: true },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
{ input: true },
|
||||
{ input: false },
|
||||
],
|
||||
};
|
||||
Reference in New Issue
Block a user