3
4
```javascript
5
// @enableEarlyReturnInReactiveScopes
6
+import { makeArray } from "shared-runtime";
7
+
8
function Component(props) {
9
let x = [];
10
if (props.cond) {
12
// oops no memo!
13
return x;
14
} else {
13
- return foo();
15
+ return makeArray(props.b);
16
}
17
}
18
19
export const FIXTURE_ENTRYPOINT = {
20
fn: Component,
19
- params: [{ cond: true, a: 42 }],
21
+ params: [],
22
+ sequentialRenders: [
23
+ // pattern 1
24
+ { cond: true, a: 42 },
25
+ { cond: true, a: 42 },
26
+ // pattern 2
27
+ { cond: false, b: 3.14 },
28
+ { cond: false, b: 3.14 },
29
+ // pattern 1
30
+ { cond: true, a: 42 },
31
+ // pattern 2
32
+ { cond: false, b: 3.14 },
33
+ // pattern 1
34
+ { cond: true, a: 42 },
35
+ // pattern 2
36
+ { cond: false, b: 3.14 },
37
+ ],
38
};
39
40
```
43
44
```javascript
45
import { unstable_useMemoCache as useMemoCache } from "react"; // @enableEarlyReturnInReactiveScopes
46
+import { makeArray } from "shared-runtime";
47
+
48
function Component(props) {
29
- const $ = useMemoCache(3);
30
- let t29;
49
+ const $ = useMemoCache(4);
50
+ let t33;
51
if ($[0] !== props) {
32
- t29 = Symbol.for("react.memo_cache_sentinel");
52
+ t33 = Symbol.for("react.memo_cache_sentinel");
53
bb8: {
54
const x = [];
55
if (props.cond) {
56
x.push(props.a);
37
- t29 = x;
57
+ t33 = x;
58
break bb8;
59
} else {
60
let t0;
41
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
42
- t0 = foo();
43
- $[2] = t0;
61
+ if ($[2] !== props.b) {
62
+ t0 = makeArray(props.b);
63
+ $[2] = props.b;
64
+ $[3] = t0;
65
} else {
45
- t0 = $[2];
66
+ t0 = $[3];
67
}
47
- t29 = t0;
68
+ t33 = t0;
69
break bb8;
70
}
71
}
72
$[0] = props;
52
- $[1] = t29;
73
+ $[1] = t33;
74
} else {
54
- t29 = $[1];
75
+ t33 = $[1];
76
}
56
- if (t29 !== Symbol.for("react.memo_cache_sentinel")) {
57
- return t29;
77
+ if (t33 !== Symbol.for("react.memo_cache_sentinel")) {
78
+ return t33;
79
}
80
}
81
82
export const FIXTURE_ENTRYPOINT = {
83
fn: Component,
63
- params: [{ cond: true, a: 42 }],
84
+ params: [],
85
+ sequentialRenders: [
86
+ // pattern 1
87
+ { cond: true, a: 42 },
88
+ { cond: true, a: 42 },
89
+ // pattern 2
90
+ { cond: false, b: 3.14 },
91
+ { cond: false, b: 3.14 },
92
+ // pattern 1
93
+ { cond: true, a: 42 },
94
+ // pattern 2
95
+ { cond: false, b: 3.14 },
96
+ // pattern 1
97
+ { cond: true, a: 42 },
98
+ // pattern 2
99
+ { cond: false, b: 3.14 },
100
+ ],
101
};
102
103
```
104
105
### Eval output
69
-(kind: ok) [42]
\ No newline at end of file
106
+(kind: ok) [42]
107
+[42]
108
+[3.14]
109
+[3.14]
110
+[42]
111
+[3.14]
112
+[42]
113
+[3.14]
\ No newline at end of file