1
+
2
+## Input
3
+
4
+```javascript
5
+import { useCallback, useRef } from "react";
6
+
7
+// Identical to useCallback-set-ref-nested-property-preserve-memoization,
8
+// but with a different set of compiler flags
9
+function Component({}) {
10
+ const ref = useRef({ inner: null });
11
+
12
+ const onChange = useCallback((event) => {
13
+ // The ref should still be mutable here even though function deps are frozen in
14
+ // @enablePreserveExistingMemoizationGuarantees mode
15
+ ref.current.inner = event.target.value;
16
+ });
17
+
18
+ return <input onChange={onChange} />;
19
+}
20
+
21
+export const FIXTURE_ENTRYPOINT = {
22
+ fn: Component,
23
+ params: [{}],
24
+};
25
+
26
+```
27
+
28
+## Code
29
+
30
+```javascript
31
+import {
32
+ useCallback,
33
+ useRef,
34
+ unstable_useMemoCache as useMemoCache,
35
+} from "react";
36
+
37
+// Identical to useCallback-set-ref-nested-property-preserve-memoization,
38
+// but with a different set of compiler flags
39
+function Component(t27) {
40
+ const $ = useMemoCache(4);
41
+ let t0;
42
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
43
+ t0 = { inner: null };
44
+ $[0] = t0;
45
+ } else {
46
+ t0 = $[0];
47
+ }
48
+ const ref = useRef(t0);
49
+ let t1;
50
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
51
+ t1 = (event) => {
52
+ ref.current.inner = event.target.value;
53
+ };
54
+ $[1] = t1;
55
+ } else {
56
+ t1 = $[1];
57
+ }
58
+ const onChange = t1;
59
+ let t2;
60
+ if ($[2] !== onChange) {
61
+ t2 = <input onChange={onChange} />;
62
+ $[2] = onChange;
63
+ $[3] = t2;
64
+ } else {
65
+ t2 = $[3];
66
+ }
67
+ return t2;
68
+}
69
+
70
+export const FIXTURE_ENTRYPOINT = {
71
+ fn: Component,
72
+ params: [{}],
73
+};
74
+
75
+```
76
+
77
+### Eval output
78
+(kind: ok) <input>
\ No newline at end of file