1
+
2
+## Input
3
+
4
+```javascript
5
+// @compilationMode:"infer" @enablePreserveExistingMemoizationGuarantees @validatePreserveExistingMemoizationGuarantees
6
+import {useMemo} from 'react';
7
+import {makeObject_Primitives, ValidateMemoization} from 'shared-runtime';
8
+
9
+function Component(props) {
10
+ const result = useMemo(() => {
11
+ return makeObject(props.value).value + 1;
12
+ }, [props.value]);
13
+ return <ValidateMemoization inputs={[props.value]} output={result} />;
14
+}
15
+
16
+function makeObject(value) {
17
+ console.log(value);
18
+ return {value};
19
+}
20
+
21
+export const FIXTURE_ENTRYPOINT = {
22
+ fn: Component,
23
+ params: [{value: 42}],
24
+ sequentialRenders: [
25
+ {value: 42},
26
+ {value: 42},
27
+ {value: 3.14},
28
+ {value: 3.14},
29
+ {value: 42},
30
+ {value: 3.14},
31
+ {value: 42},
32
+ {value: 3.14},
33
+ ],
34
+};
35
+
36
+```
37
+
38
+## Code
39
+
40
+```javascript
41
+import { c as _c } from "react/compiler-runtime"; // @compilationMode:"infer" @enablePreserveExistingMemoizationGuarantees @validatePreserveExistingMemoizationGuarantees
42
+import { useMemo } from "react";
43
+import { makeObject_Primitives, ValidateMemoization } from "shared-runtime";
44
+
45
+function Component(props) {
46
+ const $ = _c(7);
47
+ let t0;
48
+ if ($[0] !== props.value) {
49
+ t0 = makeObject(props.value);
50
+ $[0] = props.value;
51
+ $[1] = t0;
52
+ } else {
53
+ t0 = $[1];
54
+ }
55
+ const result = t0.value + 1;
56
+ let t1;
57
+ if ($[2] !== props.value) {
58
+ t1 = [props.value];
59
+ $[2] = props.value;
60
+ $[3] = t1;
61
+ } else {
62
+ t1 = $[3];
63
+ }
64
+ let t2;
65
+ if ($[4] !== result || $[5] !== t1) {
66
+ t2 = <ValidateMemoization inputs={t1} output={result} />;
67
+ $[4] = result;
68
+ $[5] = t1;
69
+ $[6] = t2;
70
+ } else {
71
+ t2 = $[6];
72
+ }
73
+ return t2;
74
+}
75
+
76
+function makeObject(value) {
77
+ console.log(value);
78
+ return { value };
79
+}
80
+
81
+export const FIXTURE_ENTRYPOINT = {
82
+ fn: Component,
83
+ params: [{ value: 42 }],
84
+ sequentialRenders: [
85
+ { value: 42 },
86
+ { value: 42 },
87
+ { value: 3.14 },
88
+ { value: 3.14 },
89
+ { value: 42 },
90
+ { value: 3.14 },
91
+ { value: 42 },
92
+ { value: 3.14 },
93
+ ],
94
+};
95
+
96
+```
97
+
98
+### Eval output
99
+(kind: ok) <div>{"inputs":[42],"output":43}</div>
100
+<div>{"inputs":[42],"output":43}</div>
101
+<div>{"inputs":[3.14],"output":4.140000000000001}</div>
102
+<div>{"inputs":[3.14],"output":4.140000000000001}</div>
103
+<div>{"inputs":[42],"output":43}</div>
104
+<div>{"inputs":[3.14],"output":4.140000000000001}</div>
105
+<div>{"inputs":[42],"output":43}</div>
106
+<div>{"inputs":[3.14],"output":4.140000000000001}</div>
107
+logs: [42,3.14,42,3.14,42,3.14]
\ No newline at end of file