diff --git a/compiler/forget/packages/playground/lib/patchUseMemoCache.ts b/compiler/forget/packages/playground/lib/patchUseMemoCache.ts index 481c6d0636..96a1f15e59 100644 --- a/compiler/forget/packages/playground/lib/patchUseMemoCache.ts +++ b/compiler/forget/packages/playground/lib/patchUseMemoCache.ts @@ -130,7 +130,7 @@ export default function patchUseMemoCache(reactSource: string) { () => true, // always read-only ); - React.useMemoCache = useMemoCache; + React.unstable_useMemoCache = React.useMemoCache = useMemoCache; export default React; `; diff --git a/compiler/forget/src/BackEnd/JSGen.ts b/compiler/forget/src/BackEnd/JSGen.ts index 1a97c4872c..eb59965327 100644 --- a/compiler/forget/src/BackEnd/JSGen.ts +++ b/compiler/forget/src/BackEnd/JSGen.ts @@ -36,7 +36,7 @@ export function run(lirProg: LIR.Prog, context: CompilerContext) { /*specifier*/ [ t.importSpecifier( t.identifier("useMemoCache"), - t.identifier("useMemoCache") + t.identifier("unstable_useMemoCache") ), ], /*source*/ t.stringLiteral("react") diff --git a/compiler/forget/src/__tests__/e2e/hello.e2e.js b/compiler/forget/src/__tests__/e2e/hello.e2e.js index d35f16f9c2..ed76812cdb 100644 --- a/compiler/forget/src/__tests__/e2e/hello.e2e.js +++ b/compiler/forget/src/__tests__/e2e/hello.e2e.js @@ -10,7 +10,7 @@ import * as React from "react"; import { render } from "@testing-library/react"; import { expectLogsAndClear, log } from "./expectLogs"; -React.useMemoCache = useMemoCacheStub; +React.unstable_useMemoCache = useMemoCacheStub; function Hello({ name }) { "use forget"; diff --git a/compiler/forget/src/__tests__/e2e/update-button.e2e.js b/compiler/forget/src/__tests__/e2e/update-button.e2e.js index 008bc5b59d..11cae8dc82 100644 --- a/compiler/forget/src/__tests__/e2e/update-button.e2e.js +++ b/compiler/forget/src/__tests__/e2e/update-button.e2e.js @@ -9,7 +9,7 @@ import { render } from "@testing-library/react"; import * as React from "react"; import { useMemoCacheStub } from "../test-utils/useMemoCacheStub"; -React.useMemoCache = useMemoCacheStub; +React.unstable_useMemoCache = useMemoCacheStub; function Button({ label }) { const theme = useTheme(); diff --git a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md index 7c236f2afe..05808f35db 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/call.expect.md @@ -53,7 +53,6 @@ function Component$0(props$1) { const b$3 = {}; foo$4(a$2, b$3); let _$5 =
; - foo$4(b$3); return
; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md index 6c27c54b52..703b59f405 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-break.expect.md @@ -98,7 +98,6 @@ function Component$0(props$1) { if (props$1.b) { return null; } - a_DEBUG$2.push(props$1.d); return a_DEBUG$2; } @@ -129,7 +128,6 @@ function Component$0(props$1) { a$2.push(props$1.c); ("<>"); } - a$2.push(props$1.d); return a$2; } @@ -161,7 +159,6 @@ function Component$0(props$1) { a$2.push(props$1.c); return null; } - a$2.push(props$1.d); return a$2; } @@ -192,7 +189,6 @@ function Component$0(props$1) { a$2.push(props$1.c); return a$2; } - a$2.push(props$1.d); return a$2; } @@ -223,7 +219,6 @@ function Component$0(props$1) { a$2.push(props$1.d); return a$2; } - a$2.push(props$1.c); ("<>"); } diff --git a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md index 7d95dfd50c..2cc637df05 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/conditional-on-mutable.expect.md @@ -93,12 +93,10 @@ function Component$0(props$1) { a$2.push(props$1.p0); ("<>"); } - if (props$1.p1) { b$3.push(props$1.p2); ("<>"); } - return ; } @@ -134,12 +132,10 @@ function Component$0(props$1) { a$2.push(props$1.p0); ("<>"); } - if (props$1.p1) { b$3.push(props$1.p2); ("<>"); } - return ; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md index 0aa2ea7015..045650a9ef 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/constructor.expect.md @@ -53,7 +53,6 @@ function Component$0(props$1) { const b$3 = {}; new Foo$4(a$2, b$3); let _$5 =
; - new Foo$4(b$3); return
; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md index a0828e3d84..ffb2213e6c 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/independent-across-if.expect.md @@ -120,7 +120,6 @@ function Component$0(props$1) { mutate$5(b$4); ("<>"); } - return ; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md index 4528ebedc8..b5d8dc4883 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/interdependent-across-if.expect.md @@ -97,7 +97,6 @@ function Component$0(props$1) { foo$5(a$2, b$4); ("<>"); } - return ; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md index 1d15cafa2d..57cd445f04 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment-conditional.expect.md @@ -48,9 +48,7 @@ function Component$0(props$1) { x$2 = []; ("<>"); } - let _$4 = ; - y$3.push(props$1.p2); return ; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md index 044f294372..dcdd0301dd 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/reassignment.expect.md @@ -40,7 +40,6 @@ function Component$0(props$1) { let y$3 = x$2; x$2 = []; let _$4 = ; - y$3.push(props$1.p1); return ; } diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md index a301daf79e..d02e9e8166 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch-non-final-default.expect.md @@ -65,22 +65,18 @@ function Component$0(props$1) { switch (props$1.p0) { case 1: break; - case true: { x$2.push(props$1.p2); y$3 = []; ("<>"); } - default: break; - case false: { y$3 = x$2; ("<>"); } } - const child$7 = ; y$3.push(props$1.p4); return {child$7}; diff --git a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md index e10639f01a..f267daf383 100644 --- a/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/hir/switch.expect.md @@ -64,13 +64,11 @@ function Component$0(props$1) { y$3 = []; ("<>"); } - case false: { y$3 = x$2; ("<>"); } } - const child$6 = ; y$3.push(props$1.p4); return {child$6};