Import useMemoCache from unstable name
I didn't make this an option as it's unclear we'll really need this. We can always add an option later, I think. This is the name that's available on facebook.com at the moment.
Jan Kassens committed
Oct 11, 2022 at 13:16 UTC
7f17dd84d1504b67f35eecb1703bf0367411903d
14 files changed
+4
-26
compiler/forget/packages/playground/lib/patchUseMemoCache.ts
+1
-1
@@ -130,7 +130,7 @@ export default function patchUseMemoCache(reactSource: string) {
130
() => true, // always read-only
131
);
132
133
- React.useMemoCache = useMemoCache;
133
+ React.unstable_useMemoCache = React.useMemoCache = useMemoCache;
134
135
export default React;
136
`;
compiler/forget/src/BackEnd/JSGen.ts
+1
-1
@@ -36,7 +36,7 @@ export function run(lirProg: LIR.Prog, context: CompilerContext) {
36
/*specifier*/ [
37
t.importSpecifier(
38
t.identifier("useMemoCache"),
39
- t.identifier("useMemoCache")
39
+ t.identifier("unstable_useMemoCache")
40
),
41
],
42
/*source*/ t.stringLiteral("react")
compiler/forget/src/__tests__/e2e/hello.e2e.js
+1
-1
@@ -10,7 +10,7 @@ import * as React from "react";
10
import { render } from "@testing-library/react";
11
import { expectLogsAndClear, log } from "./expectLogs";
12
13
-React.useMemoCache = useMemoCacheStub;
13
+React.unstable_useMemoCache = useMemoCacheStub;
14
15
function Hello({ name }) {
16
"use forget";
compiler/forget/src/__tests__/e2e/update-button.e2e.js
+1
-1
@@ -9,7 +9,7 @@ import { render } from "@testing-library/react";
9
import * as React from "react";
10
import { useMemoCacheStub } from "../test-utils/useMemoCacheStub";
11
12
-React.useMemoCache = useMemoCacheStub;
12
+React.unstable_useMemoCache = useMemoCacheStub;
13
14
function Button({ label }) {
15
const theme = useTheme();
compiler/forget/src/__tests__/fixtures/hir/call.expect.md
-1
@@ -53,7 +53,6 @@ function Component$0(props$1) {
53
const b$3 = {};
54
foo$4(a$2, b$3);
55
let _$5 = <div a={a$2}></div>;
56
-
56
foo$4(b$3);
57
return <div a={a$2} b={b$3}></div>;
58
}
compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md
-5
@@ -98,7 +98,6 @@ function Component$0(props$1) {
98
if (props$1.b) {
99
return null;
100
}
101
-
101
a_DEBUG$2.push(props$1.d);
102
return a_DEBUG$2;
103
}
@@ -129,7 +128,6 @@ function Component$0(props$1) {
128
a$2.push(props$1.c);
129
("<<TODO: handle complex control flow in codegen>>");
130
}
132
-
131
a$2.push(props$1.d);
132
return a$2;
133
}
@@ -161,7 +159,6 @@ function Component$0(props$1) {
159
a$2.push(props$1.c);
160
return null;
161
}
164
-
162
a$2.push(props$1.d);
163
return a$2;
164
}
@@ -192,7 +189,6 @@ function Component$0(props$1) {
189
a$2.push(props$1.c);
190
return a$2;
191
}
195
-
192
a$2.push(props$1.d);
193
return a$2;
194
}
@@ -223,7 +219,6 @@ function Component$0(props$1) {
219
a$2.push(props$1.d);
220
return a$2;
221
}
226
-
222
a$2.push(props$1.c);
223
("<<TODO: handle complex control flow in codegen>>");
224
}
compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md
-4
@@ -93,12 +93,10 @@ function Component$0(props$1) {
93
a$2.push(props$1.p0);
94
("<<TODO: handle complex control flow in codegen>>");
95
}
96
-
96
if (props$1.p1) {
97
b$3.push(props$1.p2);
98
("<<TODO: handle complex control flow in codegen>>");
99
}
101
-
100
return <Foo$4 a={a$2} b={b$3}></Foo$4>;
101
}
102
@@ -134,12 +132,10 @@ function Component$0(props$1) {
132
a$2.push(props$1.p0);
133
("<<TODO: handle complex control flow in codegen>>");
134
}
137
-
135
if (props$1.p1) {
136
b$3.push(props$1.p2);
137
("<<TODO: handle complex control flow in codegen>>");
138
}
142
-
139
return <Foo$6 a={a$2} b={b$3}></Foo$6>;
140
}
141
compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md
-1
@@ -53,7 +53,6 @@ function Component$0(props$1) {
53
const b$3 = {};
54
new Foo$4(a$2, b$3);
55
let _$5 = <div a={a$2}></div>;
56
-
56
new Foo$4(b$3);
57
return <div a={a$2} b={b$3}></div>;
58
}
compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md
-1
@@ -120,7 +120,6 @@ function Component$0(props$1) {
120
mutate$5(b$4);
121
("<<TODO: handle complex control flow in codegen>>");
122
}
123
-
123
return <Foo$6 a={a$2} b={b$4}></Foo$6>;
124
}
125
compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md
-1
@@ -97,7 +97,6 @@ function Component$0(props$1) {
97
foo$5(a$2, b$4);
98
("<<TODO: handle complex control flow in codegen>>");
99
}
100
-
100
return <Foo$6 a={a$2} b={b$4}></Foo$6>;
101
}
102
compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md
-2
@@ -48,9 +48,7 @@ function Component$0(props$1) {
48
x$2 = [];
49
("<<TODO: handle complex control flow in codegen>>");
50
}
51
-
51
let _$4 = <Component$0 x={x$2}></Component$0>;
53
-
52
y$3.push(props$1.p2);
53
return <Component$0 x={x$2} y={y$3}></Component$0>;
54
}
compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md
-1
@@ -40,7 +40,6 @@ function Component$0(props$1) {
40
let y$3 = x$2;
41
x$2 = [];
42
let _$4 = <Component$0 x={x$2}></Component$0>;
43
-
43
y$3.push(props$1.p1);
44
return <Component$0 x={x$2} y={y$3}></Component$0>;
45
}
compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md
-4
@@ -65,22 +65,18 @@ function Component$0(props$1) {
65
switch (props$1.p0) {
66
case 1:
67
break;
68
-
68
case true: {
69
x$2.push(props$1.p2);
70
y$3 = [];
71
("<<TODO: handle complex control flow in codegen>>");
72
}
74
-
73
default:
74
break;
77
-
75
case false: {
76
y$3 = x$2;
77
("<<TODO: handle complex control flow in codegen>>");
78
}
79
}
83
-
80
const child$7 = <Component$0 data={x$2}></Component$0>;
81
y$3.push(props$1.p4);
82
return <Component$0 data={y$3}>{child$7}</Component$0>;
compiler/forget/src/__tests__/fixtures/hir/switch.expect.md
-2
@@ -64,13 +64,11 @@ function Component$0(props$1) {
64
y$3 = [];
65
("<<TODO: handle complex control flow in codegen>>");
66
}
67
-
67
case false: {
68
y$3 = x$2;
69
("<<TODO: handle complex control flow in codegen>>");
70
}
71
}
73
-
72
const child$6 = <Component$0 data={x$2}></Component$0>;
73
y$3.push(props$1.p4);
74
return <Component$0 data={y$3}>{child$6}</Component$0>;