[babel] Alias unstable_useMemoCache to useMemoCache

DevTools relies on built-in hook names at their call site to be unprefixed in 

order to correctly track them. This PR updates our Babel plugin to: 

- Check if there are any existing import declarations of `import { /* ... /* } 
from 'react';` 

- If true, we add the specifier `unstable_useMemoCache as useMemoCache` 

- Otherwise, we synthesize a new import declaration 

- In Codegen we now emit `useMemoCache(n)` rather than 
`React.unstable_useMemoCache(n)`
This commit is contained in:
Lauren Tan
2023-04-26 13:40:22 -04:00
parent 32dccd48d2
commit a6769df6b1
284 changed files with 747 additions and 626 deletions
+51 -23
View File
@@ -214,48 +214,76 @@ export default function ReactForgetBabelPlugin(
opts: { ...pass.opts, ...options },
});
// If there isn't already an import of * as React, insert it so React.useMemoCache doesn't
// If there isn't already an import of * as React, insert it so useMemoCache doesn't
// throw
if (hasForgetCompiledCode) {
let didInsertUseMemoCache = false;
let hasExistingReactImport = false;
path.traverse({
MemberExpression(memberExprPath) {
const obj = memberExprPath.get("object");
const prop = memberExprPath.get("property");
CallExpression(callExprPath) {
const callee = callExprPath.get("callee");
const args = callExprPath.get("arguments");
if (
obj.isIdentifier() &&
obj.node.name === "React" &&
prop.isIdentifier() &&
prop.node.name === "unstable_useMemoCache"
callee.isIdentifier() &&
callee.node.name === "useMemoCache" &&
args.length === 1 &&
args[0].isNumericLiteral()
) {
didInsertUseMemoCache = true;
memberExprPath.stop();
}
},
ImportDeclaration(importDeclPath) {
// Matches `import { /* ... */ } from 'react';`
// but not `import * as React from 'react';`
if (
importDeclPath.get("source").node.value === "react" &&
importDeclPath.get("specifiers").length === 1 &&
importDeclPath
.get("specifiers")[0]
.isImportNamespaceSpecifier() &&
importDeclPath.get("specifiers")[0].get("local").node.name ===
"React"
.get("specifiers")
.every((specifier) => specifier.isImportSpecifier())
) {
hasExistingReactImport = true;
importDeclPath.stop();
}
},
});
if (didInsertUseMemoCache && !hasExistingReactImport) {
path.unshiftContainer(
"body",
t.importDeclaration(
[t.importNamespaceSpecifier(t.identifier("React"))],
t.stringLiteral("react")
)
);
// If Forget did successfully compile inject/update an import of
// `import {unstable_useMemoCache as useMemoCache} from 'react'` and rename
// `React.unstable_useMemoCache(n)` to `useMemoCache(n)`;
if (didInsertUseMemoCache) {
if (hasExistingReactImport) {
let didUpdateImport = false;
path.traverse({
ImportDeclaration(importDeclPath) {
if (importDeclPath.get("source").node.value === "react") {
importDeclPath.pushContainer(
"specifiers",
t.importSpecifier(
t.identifier("useMemoCache"),
t.identifier("unstable_useMemoCache")
)
);
didUpdateImport = true;
}
},
});
if (didUpdateImport === false) {
throw new Error(
"Expected an ImportDeclaration of react in order to update ImportSpecifiers with useMemoCache"
);
}
} else {
path.unshiftContainer(
"body",
t.importDeclaration(
[
t.importSpecifier(
t.identifier("useMemoCache"),
t.identifier("unstable_useMemoCache")
),
],
t.stringLiteral("react")
)
);
}
}
if (options.gating != null) {
path.unshiftContainer(
@@ -54,17 +54,14 @@ export function codegenReactiveFunction(
}
const cacheCount = cx.nextCacheIndex;
if (cacheCount !== 0) {
// The import declaration for `useMemoCache` is inserted in the Babel plugin
statements.unshift(
t.variableDeclaration("const", [
t.variableDeclarator(
t.identifier("$"),
t.callExpression(
t.memberExpression(
t.identifier("React"),
t.identifier("unstable_useMemoCache")
),
[t.numericLiteral(cacheCount)]
)
t.callExpression(t.identifier("useMemoCache"), [
t.numericLiteral(cacheCount),
])
),
])
);
@@ -23,13 +23,13 @@ function Component() {
## Code
```javascript
import * as React from "react"; // Should print A, B, arg, original
import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, B, arg, original
function changeF(o) {
o.f = () => console.log("new");
}
function Component() {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = () => console.log("original");
@@ -23,9 +23,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
let t0;
let t1;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -19,9 +19,9 @@ function Component() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component() {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = {};
@@ -22,14 +22,14 @@ function Component() {
## Code
```javascript
import * as React from "react"; // Should print A, arg, original
import { unstable_useMemoCache as useMemoCache } from "react"; // Should print A, arg, original
function changeF(o) {
o.f = () => console.log("new");
}
function Component() {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = () => console.log("original");
@@ -16,9 +16,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let x;
if (c_0) {
@@ -17,9 +17,9 @@ function component() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component() {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let x;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const z = [];
@@ -16,9 +16,9 @@ function component() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component() {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = [];
@@ -26,9 +26,9 @@ function mutate(x, y) {}
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo(cond) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== cond;
let a;
if (c_0) {
@@ -19,12 +19,12 @@ function AllocatingPrimitiveAsDepNested(props) {
## Code
```javascript
import * as React from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
import { unstable_useMemoCache as useMemoCache } from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
// that Forget should memoize it.
// Correctness:
// - y depends on either bar(props.b) or bar(props.b) + 1
function AllocatingPrimitiveAsDepNested(props) {
const $ = React.unstable_useMemoCache(9);
const $ = useMemoCache(9);
const c_0 = $[0] !== props.b;
const c_1 = $[1] !== props.a;
let x;
@@ -16,12 +16,12 @@ function AllocatingPrimitiveAsDep(props) {
## Code
```javascript
import * as React from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
import { unstable_useMemoCache as useMemoCache } from "react"; // bar(props.b) is an allocating expression that produces a primitive, which means
// that Forget should memoize it.
// Correctness:
// - y depends on either bar(props.b) or bar(props.b) + 1
function AllocatingPrimitiveAsDep(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const t0 = bar(props).b + 1;
const c_0 = $[0] !== t0;
let t1;
@@ -16,9 +16,9 @@ function foo(a, b, c) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo(a, b, c) {
const $ = React.unstable_useMemoCache(10);
const $ = useMemoCache(10);
const c_0 = $[0] !== a;
const c_1 = $[1] !== b;
const c_2 = $[2] !== c;
@@ -17,9 +17,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const c_0 = $[0] !== props.x;
let t0;
if (c_0) {
@@ -17,12 +17,12 @@ function ArrayAtTest(props) {
## Code
```javascript
import * as React from "react"; // arrayInstance.at should have the following effects:
import { unstable_useMemoCache as useMemoCache } from "react"; // arrayInstance.at should have the following effects:
// - read on arg0
// - read on receiver
// - mutate on lvalue
function ArrayAtTest(props) {
const $ = React.unstable_useMemoCache(9);
const $ = useMemoCache(9);
const c_0 = $[0] !== props.x;
let t0;
if (c_0) {
@@ -18,10 +18,10 @@ function Component(props) {
## Code
```javascript
import * as React from "react"; // x's mutable range should extend to `mutate(y)`
import { unstable_useMemoCache as useMemoCache } from "react"; // x's mutable range should extend to `mutate(y)`
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = {};
@@ -12,9 +12,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== props.foo;
const c_1 = $[1] !== props.bar;
let t0;
@@ -13,9 +13,9 @@ function component([a, b]) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(t17) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const [a, b] = t17;
const c_0 = $[0] !== a;
let t0;
@@ -14,9 +14,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
let t0;
@@ -15,9 +15,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(11);
const $ = useMemoCache(11);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
let t0;
@@ -19,11 +19,11 @@ function Component(props) {
## Code
```javascript
import * as React from "react"; // arrayInstance.push should have the following effects:
import { unstable_useMemoCache as useMemoCache } from "react"; // arrayInstance.push should have the following effects:
// - read on all args (rest parameter)
// - mutate on receiver
function Component(props) {
const $ = React.unstable_useMemoCache(8);
const $ = useMemoCache(8);
const c_0 = $[0] !== props.x;
let t0;
if (c_0) {
@@ -13,12 +13,12 @@ export default ErrorView;
```javascript
import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag";
import * as React from "react"; // @gating
import { unstable_useMemoCache as useMemoCache } from "react"; // @gating
function ErrorView_uncompiled(error, _retry) {
return <MessageBox error={error}></MessageBox>;
}
function ErrorView_forget(error, _retry) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== error;
let t0;
if (c_0) {
@@ -15,9 +15,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.x;
let x;
if (c_0) {
@@ -14,9 +14,9 @@ function g(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function g(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.c;
let a;
if (c_0) {
@@ -19,9 +19,9 @@ function useBar(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function useBar(props) {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let z;
if (props.a) {
if (props.b) {
@@ -14,9 +14,9 @@ function foo() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo() {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = [1];
@@ -14,9 +14,9 @@ function g() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function g() {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let x;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
x = { y: { z: 1 } };
@@ -13,9 +13,9 @@ async function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
async function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.id;
let x;
if (c_0) {
@@ -12,9 +12,9 @@ async function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
async function Component(props) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== props.id;
let t0;
if (c_0) {
@@ -2,18 +2,17 @@
## Input
```javascript
import * as React from "react";
import { useMemo } from "react";
import { useState, useMemo } from "react";
function Component(props) {
const [x] = React.useState(0);
const [x] = useState(0);
const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
function Component2(props) {
const [x] = React.useState(0);
const [x] = useState(0);
const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
@@ -24,49 +23,60 @@ function Component2(props) {
## Code
```javascript
import * as React from "react";
import { useMemo } from "react";
import {
useState,
useMemo,
unstable_useMemoCache as useMemoCache,
} from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(4);
const [x] = useState(0);
const c_0 = $[0] !== x;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const [x] = React.useState(0);
if (c_0) {
t0 = calculateExpensiveNumber(x);
$[0] = t0;
$[0] = x;
$[1] = t0;
} else {
t0 = $[0];
t0 = $[1];
}
const t17 = t0;
const expensiveNumber = t17;
const t16 = t0;
const expensiveNumber = t16;
const c_2 = $[2] !== expensiveNumber;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
if (c_2) {
t1 = <div>{expensiveNumber}</div>;
$[1] = t1;
$[2] = expensiveNumber;
$[3] = t1;
} else {
t1 = $[1];
t1 = $[3];
}
return t1;
}
function Component2(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(4);
const [x] = useState(0);
const c_0 = $[0] !== x;
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const [x] = React.useState(0);
if (c_0) {
t0 = calculateExpensiveNumber(x);
$[0] = t0;
$[0] = x;
$[1] = t0;
} else {
t0 = $[0];
t0 = $[1];
}
const t17 = t0;
const expensiveNumber = t17;
const t16 = t0;
const expensiveNumber = t16;
const c_2 = $[2] !== expensiveNumber;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
if (c_2) {
t1 = <div>{expensiveNumber}</div>;
$[1] = t1;
$[2] = expensiveNumber;
$[3] = t1;
} else {
t1 = $[1];
t1 = $[3];
}
return t1;
}
@@ -1,15 +1,14 @@
import * as React from "react";
import { useMemo } from "react";
import { useState, useMemo } from "react";
function Component(props) {
const [x] = React.useState(0);
const [x] = useState(0);
const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
function Component2(props) {
const [x] = React.useState(0);
const [x] = useState(0);
const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
@@ -0,0 +1,72 @@
## Input
```javascript
import * as React from "react";
function Component(props) {
const [x] = React.useState(0);
const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
function Component2(props) {
const [x] = React.useState(0);
const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
```
## Code
```javascript
import { unstable_useMemoCache as useMemoCache } from "react";
import * as React from "react";
function Component(props) {
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const [x] = React.useState(0);
t0 = React.useMemo(() => calculateExpensiveNumber(x), [x]);
$[0] = t0;
} else {
t0 = $[0];
}
const expensiveNumber = t0;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <div>{expensiveNumber}</div>;
$[1] = t1;
} else {
t1 = $[1];
}
return t1;
}
function Component2(props) {
const $ = useMemoCache(2);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const [x] = React.useState(0);
t0 = React.useMemo(() => calculateExpensiveNumber(x), [x]);
$[0] = t0;
} else {
t0 = $[0];
}
const expensiveNumber = t0;
let t1;
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
t1 = <div>{expensiveNumber}</div>;
$[1] = t1;
} else {
t1 = $[1];
}
return t1;
}
```
@@ -0,0 +1,15 @@
import * as React from "react";
function Component(props) {
const [x] = React.useState(0);
const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
function Component2(props) {
const [x] = React.useState(0);
const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]);
return <div>{expensiveNumber}</div>;
}
@@ -13,9 +13,9 @@ function component(t) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(t) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const { a } = t;
const c_0 = $[0] !== a;
let t0;
@@ -13,9 +13,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let x;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
x = makeObject();
@@ -13,9 +13,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let x;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
x = makeObject();
@@ -12,9 +12,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
let t0;
@@ -17,9 +17,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== props;
let t2;
if (c_0) {
@@ -18,11 +18,11 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo() {}
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
let a;
let b;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -19,9 +19,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(9);
const $ = useMemoCache(9);
const c_0 = $[0] !== b;
let t0;
if (c_0) {
@@ -19,9 +19,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let x;
if (c_0) {
@@ -45,9 +45,9 @@ function getNativeLogFunction(level) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function getNativeLogFunction(level) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== level;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let z;
if (c_0) {
@@ -15,9 +15,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -19,9 +19,9 @@ function component(foo, bar) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(foo, bar) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== foo;
const c_1 = $[1] !== bar;
let x;
@@ -19,9 +19,9 @@ function component(foo, bar) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(foo, bar) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== foo;
const c_1 = $[1] !== bar;
let x;
@@ -19,9 +19,9 @@ function component(foo, bar) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(foo, bar) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== foo;
const c_1 = $[1] !== bar;
let y;
@@ -19,9 +19,9 @@ function component(foo, bar) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(foo, bar) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== foo;
const c_1 = $[1] !== bar;
let y;
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const c_0 = $[0] !== b;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const c_0 = $[0] !== b;
let t0;
if (c_0) {
@@ -16,9 +16,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let x;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const c_0 = $[0] !== a;
const c_1 = $[1] !== b;
let x;
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -15,9 +15,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function bar(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function bar(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -19,9 +19,9 @@ function bar(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function bar(a, b) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== a;
const c_1 = $[1] !== b;
let y;
@@ -17,9 +17,9 @@ function bar(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function bar(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -17,9 +17,9 @@ function bar(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function bar(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let y;
if (c_0) {
@@ -22,9 +22,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const c_0 = $[0] !== a;
let z;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -16,9 +16,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let t;
if (c_0) {
@@ -18,9 +18,9 @@ function Foo(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Foo(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.router.location;
let t0;
if (c_0) {
@@ -19,9 +19,9 @@ function component({ mutator }) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(t27) {
const $ = React.unstable_useMemoCache(7);
const $ = useMemoCache(7);
const { mutator } = t27;
const c_0 = $[0] !== mutator;
let t0;
@@ -18,9 +18,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -13,9 +13,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -16,9 +16,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let t0;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
t0 = function () {
@@ -12,9 +12,9 @@ function StoreLandingUnseenGiftModalContainer(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function StoreLandingUnseenGiftModalContainer(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -18,9 +18,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -15,9 +15,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -15,9 +15,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -15,9 +15,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -17,9 +17,9 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -16,9 +16,9 @@ function foo() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo() {
const $ = React.unstable_useMemoCache(1);
const $ = useMemoCache(1);
let z;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
const x = { x: 0 };
@@ -34,9 +34,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(8);
const $ = useMemoCache(8);
const items = props.items;
const maxItems = props.maxItems;
const c_0 = $[0] !== maxItems;
@@ -12,9 +12,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== props.method;
const c_1 = $[1] !== props.a;
const c_2 = $[2] !== props.b;
@@ -17,9 +17,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const a = foo();
const t0 = a[props.a] + 1;
@@ -15,9 +15,9 @@ function component(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component(a, b) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== a;
const c_1 = $[1] !== b;
let x;
@@ -13,9 +13,9 @@ function component() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component() {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const [x, setX] = useState(0);
const c_0 = $[0] !== setX;
let t0;
@@ -17,12 +17,12 @@ function Component(props) {
## Code
```javascript
import * as React from "react"; // To preserve the nullthrows behavior and reactive deps of this code,
import { unstable_useMemoCache as useMemoCache } from "react"; // To preserve the nullthrows behavior and reactive deps of this code,
// Forget needs to add `props.a` as a dependency (since `props.a.b` is
// a conditional dependency, i.e. gated behind control flow)
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.a;
let x;
if (c_0) {
@@ -23,12 +23,12 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
/**
* props.b *does* influence `a`
*/
function Component(props) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
const c_2 = $[2] !== props.c;
@@ -61,12 +61,12 @@ function ComponentD(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
/**
* props.b does *not* influence `a`
*/
function ComponentA(props) {
const $ = React.unstable_useMemoCache(4);
const $ = useMemoCache(4);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
const c_2 = $[2] !== props.d;
@@ -93,7 +93,7 @@ function ComponentA(props) {
* props.b *does* influence `a`
*/
function ComponentB(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props;
let a;
if (c_0) {
@@ -116,7 +116,7 @@ function ComponentB(props) {
* props.b *does* influence `a`, but only in a way that is never observable
*/
function ComponentC(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props;
let a;
if (c_0) {
@@ -140,7 +140,7 @@ function ComponentC(props) {
* props.b *does* influence `a`
*/
function ComponentD(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props;
let a;
if (c_0) {
@@ -34,9 +34,9 @@ function mayMutate() {}
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function ComponentA(props) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== props;
let a;
let b;
@@ -71,7 +71,7 @@ function ComponentA(props) {
}
function ComponentB(props) {
const $ = React.unstable_useMemoCache(6);
const $ = useMemoCache(6);
const c_0 = $[0] !== props;
let a;
let b;
@@ -15,9 +15,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== props.foo;
let x;
if (c_0) {
@@ -18,11 +18,11 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Foo() {}
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
let a;
let b;
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
@@ -13,9 +13,9 @@ function component() {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function component() {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const [x, setX] = useState(0);
const c_0 = $[0] !== setX;
let t0;
@@ -14,9 +14,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
let x;
@@ -13,9 +13,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const c_0 = $[0] !== props.a;
const c_1 = $[1] !== props.b;
let x;
@@ -22,9 +22,9 @@ function foo(a, b) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo(a, b) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const c_0 = $[0] !== a;
let x;
if (c_0) {
@@ -23,9 +23,9 @@ function foo(x, y, z) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo(x, y, z) {
const $ = React.unstable_useMemoCache(3);
const $ = useMemoCache(3);
const items = [z];
items.push(x);
const c_0 = $[0] !== x;
@@ -13,10 +13,10 @@ function component(a) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
let someGlobal = {};
function component(a) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const c_0 = $[0] !== a;
let t0;
if (c_0) {
@@ -12,9 +12,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const [t0] = props.y;
const c_0 = $[0] !== t0;
let t1;
@@ -17,9 +17,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
let x = undefined;
if (props.cond) {
const [t0] = props.y;
@@ -26,9 +26,9 @@ function foo(a, b, c) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function foo(a, b, c) {
const $ = React.unstable_useMemoCache(5);
const $ = useMemoCache(5);
const [d, t47] = a;
const [t49] = t47;
@@ -12,9 +12,9 @@ function Component(props) {
## Code
```javascript
import * as React from "react";
import { unstable_useMemoCache as useMemoCache } from "react";
function Component(props) {
const $ = React.unstable_useMemoCache(2);
const $ = useMemoCache(2);
const { x: t0 } = props.y;
const c_0 = $[0] !== t0;
let t1;

Some files were not shown because too many files have changed in this diff Show More