mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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.
This commit is contained in:
@@ -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;
|
||||
`;
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -53,7 +53,6 @@ function Component$0(props$1) {
|
||||
const b$3 = {};
|
||||
foo$4(a$2, b$3);
|
||||
let _$5 = <div a={a$2}></div>;
|
||||
|
||||
foo$4(b$3);
|
||||
return <div a={a$2} b={b$3}></div>;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
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);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
@@ -93,12 +93,10 @@ function Component$0(props$1) {
|
||||
a$2.push(props$1.p0);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
if (props$1.p1) {
|
||||
b$3.push(props$1.p2);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
return <Foo$4 a={a$2} b={b$3}></Foo$4>;
|
||||
}
|
||||
|
||||
@@ -134,12 +132,10 @@ function Component$0(props$1) {
|
||||
a$2.push(props$1.p0);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
if (props$1.p1) {
|
||||
b$3.push(props$1.p2);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
return <Foo$6 a={a$2} b={b$3}></Foo$6>;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,6 @@ function Component$0(props$1) {
|
||||
const b$3 = {};
|
||||
new Foo$4(a$2, b$3);
|
||||
let _$5 = <div a={a$2}></div>;
|
||||
|
||||
new Foo$4(b$3);
|
||||
return <div a={a$2} b={b$3}></div>;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,6 @@ function Component$0(props$1) {
|
||||
mutate$5(b$4);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
return <Foo$6 a={a$2} b={b$4}></Foo$6>;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ function Component$0(props$1) {
|
||||
foo$5(a$2, b$4);
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
return <Foo$6 a={a$2} b={b$4}></Foo$6>;
|
||||
}
|
||||
|
||||
|
||||
@@ -48,9 +48,7 @@ function Component$0(props$1) {
|
||||
x$2 = [];
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
let _$4 = <Component$0 x={x$2}></Component$0>;
|
||||
|
||||
y$3.push(props$1.p2);
|
||||
return <Component$0 x={x$2} y={y$3}></Component$0>;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ function Component$0(props$1) {
|
||||
let y$3 = x$2;
|
||||
x$2 = [];
|
||||
let _$4 = <Component$0 x={x$2}></Component$0>;
|
||||
|
||||
y$3.push(props$1.p1);
|
||||
return <Component$0 x={x$2} y={y$3}></Component$0>;
|
||||
}
|
||||
|
||||
@@ -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 = [];
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
default:
|
||||
break;
|
||||
|
||||
case false: {
|
||||
y$3 = x$2;
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
}
|
||||
|
||||
const child$7 = <Component$0 data={x$2}></Component$0>;
|
||||
y$3.push(props$1.p4);
|
||||
return <Component$0 data={y$3}>{child$7}</Component$0>;
|
||||
|
||||
@@ -64,13 +64,11 @@ function Component$0(props$1) {
|
||||
y$3 = [];
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
|
||||
case false: {
|
||||
y$3 = x$2;
|
||||
("<<TODO: handle complex control flow in codegen>>");
|
||||
}
|
||||
}
|
||||
|
||||
const child$6 = <Component$0 data={x$2}></Component$0>;
|
||||
y$3.push(props$1.p4);
|
||||
return <Component$0 data={y$3}>{child$6}</Component$0>;
|
||||
|
||||
Reference in New Issue
Block a user