From a6769df6b11291d5c582a8f5783fcc7f2c61e9bb Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Wed, 26 Apr 2023 13:40:22 -0400 Subject: [PATCH] [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)` --- compiler/forget/src/Babel/BabelPlugin.ts | 74 +++++++++++++------ .../ReactiveScopes/CodegenReactiveFunction.ts | 11 +-- ...g.computed-call-evaluation-order.expect.md | 4 +- ...sx-tag-lowered-between-mutations.expect.md | 4 +- ...mbda-reassign-shadowed-primitive.expect.md | 4 +- ...g.property-call-evaluation-order.expect.md | 4 +- .../compiler/alias-computed-load.expect.md | 4 +- .../alias-nested-member-path-mutate.expect.md | 4 +- .../alias-nested-member-path.expect.md | 4 +- .../fixtures/compiler/alias-while.expect.md | 4 +- ...ng-primitive-as-dep-nested-scope.expect.md | 4 +- .../allocating-primitive-as-dep.expect.md | 4 +- .../array-access-assignment.expect.md | 4 +- .../compiler/array-at-closure.expect.md | 4 +- .../compiler/array-at-effect.expect.md | 4 +- .../array-at-mutate-after-capture.expect.md | 4 +- .../array-expression-spread.expect.md | 4 +- .../compiler/array-pattern-params.expect.md | 4 +- .../compiler/array-properties.expect.md | 4 +- .../compiler/array-property-call.expect.md | 4 +- .../compiler/array-push-effect.expect.md | 4 +- .../arrow-function-expr-gating-test.expect.md | 4 +- .../assignment-expression-computed.expect.md | 4 +- ...ssignment-expression-nested-path.expect.md | 4 +- .../assignment-in-nested-if.expect.md | 4 +- ...-variations-complex-lvalue-array.expect.md | 4 +- ...gnment-variations-complex-lvalue.expect.md | 4 +- .../await-side-effecting-promise.expect.md | 4 +- .../fixtures/compiler/await.expect.md | 4 +- .../babel-existing-react-import.expect.md | 62 +++++++++------- .../compiler/babel-existing-react-import.js | 7 +- ...-existing-react-namespace-import.expect.md | 72 ++++++++++++++++++ .../babel-existing-react-namespace-import.js | 15 ++++ .../compiler/bug_object-pattern.expect.md | 4 +- .../compiler/call-args-assignment.expect.md | 4 +- ...ll-args-destructuring-assignment.expect.md | 4 +- .../fixtures/compiler/call-spread.expect.md | 4 +- ...ith-independently-memoizable-arg.expect.md | 4 +- .../fixtures/compiler/call.expect.md | 4 +- .../capture-func-passed-to-jsx.expect.md | 4 +- .../capture-indirect-mutate-alias.expect.md | 4 +- .../compiler/capture-param-mutate.expect.md | 4 +- .../capture_mutate-across-fns.expect.md | 4 +- .../capturing-arrow-function-1.expect.md | 4 +- ...ring-fun-alias-captured-mutate-2.expect.md | 4 +- ...-fun-alias-captured-mutate-arr-2.expect.md | 4 +- ...g-func-alias-captured-mutate-arr.expect.md | 4 +- ...uring-func-alias-captured-mutate.expect.md | 4 +- ...uring-func-alias-computed-mutate.expect.md | 4 +- .../capturing-func-alias-mutate.expect.md | 4 +- ...c-alias-receiver-computed-mutate.expect.md | 4 +- ...uring-func-alias-receiver-mutate.expect.md | 4 +- .../capturing-func-mutate-2.expect.md | 4 +- .../capturing-func-mutate-3.expect.md | 4 +- .../capturing-func-mutate-nested.expect.md | 4 +- .../compiler/capturing-func-mutate.expect.md | 4 +- .../capturing-func-simple-alias.expect.md | 4 +- .../compiler/capturing-function-1.expect.md | 4 +- ...g-function-alias-computed-load-2.expect.md | 4 +- ...g-function-alias-computed-load-3.expect.md | 4 +- ...g-function-alias-computed-load-4.expect.md | 4 +- ...ing-function-alias-computed-load.expect.md | 4 +- ...nction-capture-ref-before-rename.expect.md | 4 +- ...ction-conditional-capture-mutate.expect.md | 4 +- .../capturing-function-decl.expect.md | 4 +- ...g-function-member-expr-arguments.expect.md | 4 +- ...turing-function-member-expr-call.expect.md | 4 +- .../capturing-function-renamed-ref.expect.md | 4 +- ...apturing-function-runs-inference.expect.md | 4 +- ...pturing-function-shadow-captured.expect.md | 4 +- ...ring-function-skip-computed-path.expect.md | 4 +- .../capturing-function-within-block.expect.md | 4 +- .../compiler/capturing-member-expr.expect.md | 4 +- .../capturing-nested-member-call.expect.md | 4 +- ...ested-member-expr-in-nested-func.expect.md | 4 +- .../capturing-nested-member-expr.expect.md | 4 +- ...pturing-variable-in-nested-block.expect.md | 4 +- ...ring-variable-in-nested-function.expect.md | 4 +- .../chained-assignment-expressions.expect.md | 4 +- .../fixtures/compiler/component.expect.md | 4 +- .../compiler/computed-call-spread.expect.md | 4 +- ...ted-load-primitive-as-dependency.expect.md | 4 +- .../compiler/computed-store-alias.expect.md | 4 +- .../compiler/concise-arrow-expr.expect.md | 4 +- ...ond-deps-conditional-member-expr.expect.md | 4 +- .../conditional-break-labeled.expect.md | 4 +- .../compiler/conditional-break.expect.md | 10 +-- .../compiler/conditional-on-mutable.expect.md | 6 +- .../compiler/constant-computed.expect.md | 4 +- .../fixtures/compiler/constructor.expect.md | 4 +- .../compiler/controlled-input.expect.md | 4 +- .../delete-computed-property.expect.md | 4 +- .../compiler/delete-property.expect.md | 4 +- .../compiler/dependencies-outputs.expect.md | 4 +- .../fixtures/compiler/dependencies.expect.md | 4 +- .../destructure-capture-global.expect.md | 4 +- .../destructuring-array-default.expect.md | 4 +- ...cturing-assignment-array-default.expect.md | 4 +- .../destructuring-assignment.expect.md | 4 +- .../destructuring-object-default.expect.md | 4 +- .../fixtures/compiler/destructuring.expect.md | 4 +- .../compiler/do-while-compound-test.expect.md | 4 +- .../do-while-conditional-break.expect.md | 4 +- .../compiler/do-while-continue.expect.md | 4 +- ...-while-early-unconditional-break.expect.md | 4 +- .../compiler/do-while-simple.expect.md | 4 +- ...ror.file-has-non-critical-errors.expect.md | 4 +- ...alysis-destructured-rest-element.expect.md | 4 +- .../escape-analysis-jsx-child.expect.md | 4 +- .../escape-analysis-logical.expect.md | 4 +- ...nterleaved-allocating-dependency.expect.md | 4 +- ...ved-allocating-nested-dependency.expect.md | 4 +- ...interleaved-primitive-dependency.expect.md | 4 +- .../compiler/extend-scopes-if.expect.md | 4 +- .../fbt-call-complex-param-value.expect.md | 4 +- .../fixtures/compiler/fbt-call.expect.md | 4 +- .../fbt-params-complex-param-value.expect.md | 4 +- .../fixtures/compiler/fbt-params.expect.md | 4 +- .../fixtures/compiler/for-of-break.expect.md | 4 +- .../for-of-conditional-break.expect.md | 4 +- .../compiler/for-of-continue.expect.md | 4 +- .../compiler/for-of-destructure.expect.md | 4 +- .../fixtures/compiler/for-of-mutate.expect.md | 4 +- .../fixtures/compiler/for-of-simple.expect.md | 4 +- .../compiler/frozen-after-alias.expect.md | 4 +- .../function-declaration-reassign.expect.md | 4 +- .../function-declaration-redeclare.expect.md | 4 +- .../function-declaration-simple.expect.md | 4 +- ...unction-param-assignment-pattern.expect.md | 4 +- ...ing-test-export-default-function.expect.md | 6 +- ...test-export-function-and-default.expect.md | 6 +- .../gating-test-export-function.expect.md | 6 +- .../fixtures/compiler/gating-test.expect.md | 6 +- .../fixtures/compiler/hook-call.expect.md | 4 +- .../compiler/hooks-freeze-arguments.expect.md | 4 +- ...reeze-possibly-mutable-arguments.expect.md | 4 +- ...rtent-mutability-readonly-lambda.expect.md | 4 +- .../compiler/independent-across-if.expect.md | 4 +- .../fixtures/compiler/independent.expect.md | 4 +- ...endently-memoize-object-property.expect.md | 4 +- .../compiler/infer-global-object.expect.md | 4 +- ...-promoted-to-outer-scope-dynamic.expect.md | 4 +- ...t-promoted-to-outer-scope-static.expect.md | 4 +- .../interdependent-across-if.expect.md | 4 +- .../compiler/interdependent.expect.md | 4 +- .../fixtures/compiler/inverted-if.expect.md | 4 +- ...ue933-disjoint-set-infinite-loop.expect.md | 4 +- .../compiler/jsx-empty-expression.expect.md | 4 +- .../fixtures/compiler/jsx-fragment.expect.md | 4 +- .../compiler/jsx-member-expression.expect.md | 4 +- .../compiler/jsx-namespaced-name.expect.md | 4 +- .../fixtures/compiler/jsx-spread.expect.md | 4 +- ...-tag-evaluation-order-non-global.expect.md | 4 +- .../jsx-tag-evaluation-order.expect.md | 4 +- .../lambda-capture-returned-alias.expect.md | 4 +- .../lambda-mutate-shadowed-object.expect.md | 4 +- .../logical-expression-object.expect.md | 4 +- .../compiler/method-call-computed.expect.md | 4 +- .../compiler/method-call-fn-call.expect.md | 4 +- .../fixtures/compiler/method-call.expect.md | 4 +- ...ti-arrow-expr-export-gating-test.expect.md | 6 +- .../multi-arrow-expr-gating-test.expect.md | 6 +- ...ed-function-shadowed-identifiers.expect.md | 4 +- .../nested-optional-member-expr.expect.md | 4 +- .../fixtures/compiler/new-spread.expect.md | 4 +- .../obj-literal-cached-in-if-else.expect.md | 4 +- ...bj-literal-mutated-after-if-else.expect.md | 4 +- ...mutated-after-if-else-with-alias.expect.md | 4 +- .../obj-mutated-after-if-else.expect.md | 4 +- ...-after-nested-if-else-with-alias.expect.md | 4 +- ...ct-expression-string-literal-key.expect.md | 4 +- .../object-literal-spread-element.expect.md | 4 +- .../compiler/object-pattern-params.expect.md | 4 +- ...ith-independently-memoizable-arg.expect.md | 4 +- .../fixtures/compiler/optional-call.expect.md | 4 +- ...optional-member-expression-chain.expect.md | 4 +- .../compiler/optional-method-call.expect.md | 4 +- .../optional-receiver-method-call.expect.md | 4 +- ...ptional-receiver-optional-method.expect.md | 4 +- ...ng-scopes-shadowing-within-block.expect.md | 4 +- .../overlapping-scopes-within-block.expect.md | 4 +- .../primitive-as-dep-nested-scope.expect.md | 4 +- .../compiler/primitive-as-dep.expect.md | 4 +- .../prop-capturing-function-1.expect.md | 4 +- .../compiler/property-assignment.expect.md | 4 +- .../compiler/property-call-spread.expect.md | 4 +- .../reactive-scope-grouping.expect.md | 4 +- .../compiler/reactive-scopes-if.expect.md | 4 +- .../compiler/reactive-scopes.expect.md | 4 +- ...-analysis-interleaved-reactivity.expect.md | 4 +- ...ve-via-mutation-of-computed-load.expect.md | 4 +- ...ve-via-mutation-of-property-load.expect.md | 4 +- ...temporary-accessed-outside-scope.expect.md | 4 +- .../reassignment-conditional.expect.md | 4 +- .../reassignment-separate-scopes.expect.md | 4 +- .../fixtures/compiler/reassignment.expect.md | 4 +- ...-reactive-cond-deps-cfg-condexpr.expect.md | 4 +- ...ce-reactive-cond-deps-cfg-ifelse.expect.md | 4 +- ...d-deps-cfg-nested-ifelse-missing.expect.md | 4 +- ...tive-cond-deps-cfg-nested-ifelse.expect.md | 4 +- ...ond-deps-cfg-switch-missing-case.expect.md | 4 +- ...-deps-cfg-switch-missing-default.expect.md | 4 +- ...ce-reactive-cond-deps-cfg-switch.expect.md | 4 +- ...uce-reactive-cond-deps-no-uncond.expect.md | 4 +- ...eactive-cond-deps-promote-uncond.expect.md | 4 +- ...eactive-cond-deps-subpath-order1.expect.md | 4 +- ...eactive-cond-deps-subpath-order2.expect.md | 4 +- ...ctive-cond-deps-superpath-order1.expect.md | 4 +- ...ctive-cond-deps-superpath-order2.expect.md | 4 +- ...ce-reactive-cond-memberexpr-join.expect.md | 4 +- .../reduce-reactive-deps-cond-scope.expect.md | 4 +- ...eps-join-uncond-scopes-cond-deps.expect.md | 4 +- ...ncond-deps-nonoverlap-descendant.expect.md | 4 +- ...ve-uncond-deps-nonoverlap-direct.expect.md | 4 +- ...e-uncond-deps-overlap-descendant.expect.md | 4 +- ...ctive-uncond-deps-overlap-direct.expect.md | 4 +- ...ctive-uncond-deps-subpath-order1.expect.md | 4 +- ...ctive-uncond-deps-subpath-order2.expect.md | 4 +- ...ctive-uncond-deps-subpath-order3.expect.md | 4 +- .../compiler/regexp-literal.expect.md | 4 +- ...s-dep-and-redeclare-maybe-frozen.expect.md | 4 +- ...me-variable-as-dep-and-redeclare.expect.md | 4 +- .../compiler/sequence-expression.expect.md | 4 +- .../fixtures/compiler/simple-alias.expect.md | 4 +- .../compiler/simple-function-1.expect.md | 4 +- .../fixtures/compiler/simple-scope.expect.md | 4 +- .../fixtures/compiler/simple.expect.md | 4 +- .../compiler/ssa-arrayexpression.expect.md | 4 +- .../compiler/ssa-call-jsx-2.expect.md | 4 +- .../fixtures/compiler/ssa-call-jsx.expect.md | 4 +- .../ssa-cascading-eliminated-phis.expect.md | 4 +- .../fixtures/compiler/ssa-for-of.expect.md | 4 +- .../compiler/ssa-leave-case.expect.md | 4 +- .../compiler/ssa-newexpression.expect.md | 4 +- .../ssa-non-empty-initializer.expect.md | 4 +- .../ssa-objectexpression-phi.expect.md | 4 +- .../compiler/ssa-objectexpression.expect.md | 4 +- ...a-property-alias-alias-mutate-if.expect.md | 4 +- .../compiler/ssa-property-alias-if.expect.md | 4 +- .../ssa-property-alias-mutate-if.expect.md | 4 +- ...-property-alias-mutate-inside-if.expect.md | 4 +- .../ssa-property-alias-mutate.expect.md | 4 +- .../compiler/ssa-property-call.expect.md | 4 +- .../compiler/ssa-property-mutate-2.expect.md | 4 +- .../ssa-property-mutate-alias.expect.md | 4 +- .../compiler/ssa-property-mutate.expect.md | 4 +- .../fixtures/compiler/ssa-property.expect.md | 4 +- .../compiler/ssa-reassign-in-rval.expect.md | 4 +- ...ernary-destruction-with-mutation.expect.md | 4 +- ...ssa-renaming-ternary-destruction.expect.md | 4 +- ...a-renaming-ternary-with-mutation.expect.md | 4 +- .../compiler/ssa-renaming-ternary.expect.md | 4 +- ...onditional-ternary-with-mutation.expect.md | 4 +- ...a-renaming-unconditional-ternary.expect.md | 4 +- ...ming-unconditional-with-mutation.expect.md | 4 +- ...-via-destructuring-with-mutation.expect.md | 4 +- .../ssa-renaming-via-destructuring.expect.md | 4 +- .../ssa-renaming-with-mutation.expect.md | 4 +- .../fixtures/compiler/ssa-renaming.expect.md | 4 +- .../compiler/store-via-call.expect.md | 4 +- .../fixtures/compiler/store-via-new.expect.md | 4 +- .../switch-non-final-default.expect.md | 4 +- .../fixtures/compiler/switch.expect.md | 4 +- .../tagged-template-literal.expect.md | 4 +- ...emporary-at-start-of-value-block.expect.md | 4 +- .../fixtures/compiler/timers.expect.md | 4 +- .../type-cast-expression.flow.expect.md | 4 +- .../compiler/type-field-load.expect.md | 4 +- .../type-test-field-load-binary-op.expect.md | 4 +- .../compiler/type-test-field-store.expect.md | 4 +- .../compiler/type-test-polymorphic.expect.md | 4 +- .../type-test-return-type-inference.expect.md | 4 +- .../fixtures/compiler/unary-expr.expect.md | 4 +- .../unused-object-element-with-rest.expect.md | 4 +- .../compiler/update-expression.expect.md | 4 +- .../compiler/use-callback-simple.expect.md | 4 +- .../compiler/useEffect-arg-memoized.expect.md | 4 +- .../useEffect-nested-lambdas.expect.md | 4 +- .../useMemo-if-else-multiple-return.expect.md | 4 +- ...seMemo-independently-memoizeable.expect.md | 4 +- .../useMemo-inlining-block-return.expect.md | 4 +- .../useMemo-multiple-if-else.expect.md | 4 +- .../compiler/useMemo-simple.expect.md | 4 +- .../Component.expect.md | 4 +- 284 files changed, 747 insertions(+), 626 deletions(-) create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md create mode 100644 compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.js diff --git a/compiler/forget/src/Babel/BabelPlugin.ts b/compiler/forget/src/Babel/BabelPlugin.ts index 0380706acd..1cb4257106 100644 --- a/compiler/forget/src/Babel/BabelPlugin.ts +++ b/compiler/forget/src/Babel/BabelPlugin.ts @@ -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( diff --git a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts index 4d6f152c91..3d8b246c6d 100644 --- a/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts +++ b/compiler/forget/src/ReactiveScopes/CodegenReactiveFunction.ts @@ -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), + ]) ), ]) ); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md index c76469d485..412a990f50 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.computed-call-evaluation-order.expect.md @@ -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"); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.global-jsx-tag-lowered-between-mutations.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.global-jsx-tag-lowered-between-mutations.expect.md index 773e66f71e..e53baf4519 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.global-jsx-tag-lowered-between-mutations.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.global-jsx-tag-lowered-between-mutations.expect.md @@ -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")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md index 42da1bf336..3e5a2725d7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.lambda-reassign-shadowed-primitive.expect.md @@ -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 = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md index ad665dabf4..8550eb4048 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/_bug.property-call-evaluation-order.expect.md @@ -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"); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md index 6251e27a85..44b8a6a030 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/alias-computed-load.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path-mutate.expect.md index 7e54e507b8..314219540e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path-mutate.expect.md @@ -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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path.expect.md index 5922aba3ad..a0f51955f3 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/alias-nested-member-path.expect.md @@ -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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md index ef30f567ae..1c979ac82c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/alias-while.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md index 663cff8fef..63e8ffaafa 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep-nested-scope.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md index e137d9f47a..e7831baf83 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/allocating-primitive-as-dep.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md index e5a907ae33..437d6388af 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-access-assignment.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md index c2c82da02a..330045c423 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-at-closure.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md index 9971f4b499..786fb20054 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-at-effect.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-at-mutate-after-capture.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-at-mutate-after-capture.expect.md index fd17096e2d..5f6fb257bb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-at-mutate-after-capture.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-at-mutate-after-capture.expect.md @@ -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 = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md index 643e4299b2..97919d5e72 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-expression-spread.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md index 589d335c0f..9000c19753 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-pattern-params.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-properties.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-properties.expect.md index baf036302e..369d6174ff 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-properties.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-properties.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-property-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-property-call.expect.md index ece52482ea..1f05c1f7ad 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-property-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-property-call.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md index a3646f5d06..2366c7cb86 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/array-push-effect.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md index cfe56893e1..03264d0dd1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/arrow-function-expr-gating-test.expect.md @@ -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 ; } function ErrorView_forget(error, _retry) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== error; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md index c27f69a275..bf4eb5f748 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-computed.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md index 01d8fd07f7..3be10c767f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/assignment-expression-nested-path.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/assignment-in-nested-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/assignment-in-nested-if.expect.md index a5955d7012..a2ef6e6eec 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/assignment-in-nested-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/assignment-in-nested-if.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue-array.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue-array.expect.md index ddf314aa26..b527577e96 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue-array.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue-array.expect.md @@ -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]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue.expect.md index f0676a5f86..54bf703d34 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/assignment-variations-complex-lvalue.expect.md @@ -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 } }; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md index 5494fe7fb4..5ad3a3e801 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/await-side-effecting-promise.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/await.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/await.expect.md index 5e8b27e59d..42176f985d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/await.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/await.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md index 93cd603e8a..1ad85f11ce 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.expect.md @@ -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
{expensiveNumber}
; } function Component2(props) { - const [x] = React.useState(0); + const [x] = useState(0); const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); return
{expensiveNumber}
; @@ -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 =
{expensiveNumber}
; - $[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 =
{expensiveNumber}
; - $[1] = t1; + $[2] = expensiveNumber; + $[3] = t1; } else { - t1 = $[1]; + t1 = $[3]; } return t1; } diff --git a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.js b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.js index d177f8677f..007f4bdfe1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.js +++ b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-import.js @@ -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
{expensiveNumber}
; } function Component2(props) { - const [x] = React.useState(0); + const [x] = useState(0); const expensiveNumber = useMemo(() => calculateExpensiveNumber(x), [x]); return
{expensiveNumber}
; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md new file mode 100644 index 0000000000..8128495d2e --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.expect.md @@ -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
{expensiveNumber}
; +} + +function Component2(props) { + const [x] = React.useState(0); + const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]); + + return
{expensiveNumber}
; +} + +``` + +## 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 =
{expensiveNumber}
; + $[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 =
{expensiveNumber}
; + $[1] = t1; + } else { + t1 = $[1]; + } + return t1; +} + +``` + \ No newline at end of file diff --git a/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.js b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.js new file mode 100644 index 0000000000..231a979838 --- /dev/null +++ b/compiler/forget/src/__tests__/fixtures/compiler/babel-existing-react-namespace-import.js @@ -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
{expensiveNumber}
; +} + +function Component2(props) { + const [x] = React.useState(0); + const expensiveNumber = React.useMemo(() => calculateExpensiveNumber(x), [x]); + + return
{expensiveNumber}
; +} diff --git a/compiler/forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md index a9c414f2e8..c63a1600d9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/bug_object-pattern.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call-args-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call-args-assignment.expect.md index 7d01e692a6..542095f3f9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call-args-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call-args-assignment.expect.md @@ -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(); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call-args-destructuring-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call-args-destructuring-assignment.expect.md index d00a0a0514..b7bce773d1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call-args-destructuring-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call-args-destructuring-assignment.expect.md @@ -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(); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call-spread.expect.md index 735ac5a295..d32100757b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call-spread.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md index d89109a8cd..d1b337c83b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call-with-independently-memoizable-arg.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md index e71e9f6248..8b0943f257 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/call.expect.md @@ -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")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capture-func-passed-to-jsx.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capture-func-passed-to-jsx.expect.md index 9035692176..a20f20df7f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capture-func-passed-to-jsx.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capture-func-passed-to-jsx.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md index f46388bcd4..e805e8ad75 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capture-indirect-mutate-alias.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md index 93a1b90fd0..87ca0c1427 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capture-param-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md index d7cbe62d97..7df15c6537 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capture_mutate-across-fns.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md index c017d0033b..0957e0fd95 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-arrow-function-1.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md index 9cd0fcb450..abcfecddab 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-2.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md index 705d280573..d542efe021 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-fun-alias-captured-mutate-arr-2.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md index f521060a94..447636ce63 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate-arr.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md index 5cbe2af0f8..7ce869a709 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-captured-mutate.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md index 6d535b8045..6f297a15b7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-computed-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md index d0e5f11f15..2e5f129451 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md index 9d50010d65..184374b802 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-computed-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md index 46ce0f94c5..d63e7c46b7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-alias-receiver-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md index ac5556ab06..6bb60c91d2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-2.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md index c0cc63cd9b..f6e79fc390 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-3.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md index 59898a86e9..b440fd42fa 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate-nested.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md index f65830e8ef..d4d249b3dc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-mutate.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md index 318a5a0b2e..881946930e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-func-simple-alias.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md index 886259ef99..a4db60afd7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-1.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md index 9c3b4932e5..2e6ac79476 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-2.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md index 1563181d54..e7aac3914b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-3.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md index e2ee3ad7b6..9f6226be71 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load-4.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md index 6a1858a080..009df0a730 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-alias-computed-load.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md index 51236d247c..edebe6eeef 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-capture-ref-before-rename.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md index 2e3647d3aa..af7f7c646d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-conditional-capture-mutate.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md index 14c90c8de3..e1fcc401ff 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-decl.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md index 7d190f7e11..64a15a00d1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-arguments.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md index d9ae831f0b..d355e89a51 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-member-expr-call.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md index 4c1f44fc65..2b2d047d0c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-renamed-ref.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md index b9599cac3d..c294e7eb01 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-runs-inference.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md index 58511fa70b..d8841f54d4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-shadow-captured.expect.md @@ -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 () { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md index 2bfda3e422..a6bdb500da 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-skip-computed-path.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md index 2c02fa7af3..06b742a69a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-function-within-block.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md index 8ac3d89070..b5169be829 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-member-expr.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md index 67d968814f..e298c2bf9a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-call.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md index 01179a0db8..bf8b701a45 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr-in-nested-func.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md index 3e633e3d56..2c6c59a82c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-nested-member-expr.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md index dec6f542ee..ccdc191b45 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-block.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md index a3fda1daa7..5329379a59 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/capturing-variable-in-nested-function.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/chained-assignment-expressions.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/chained-assignment-expressions.expect.md index d70f7879b3..25514aafb1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/chained-assignment-expressions.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/chained-assignment-expressions.expect.md @@ -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 }; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/component.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/component.expect.md index 82e6d7af59..a3954ed2a4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/component.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md index 3253e6b056..04af67209d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/computed-call-spread.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md index 31bfa64798..2f9e6f6f57 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/computed-load-primitive-as-dependency.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md index e154b81a29..d2c9a0e405 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/computed-store-alias.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md index 5edd392921..02c1ffe463 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/concise-arrow-expr.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md index 71ee7e6890..88fad59363 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/cond-deps-conditional-member-expr.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md index 8e24d100c5..f7213ca65d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/conditional-break-labeled.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/conditional-break.expect.md index 7ca2c4dda0..c2637c7b16 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/conditional-break.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md index 36fca5fc35..86fa304bbb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/conditional-on-mutable.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md index 2e6402abf8..762cbd0950 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/constant-computed.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md index 5d086b85d7..f71257b382 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/constructor.expect.md @@ -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")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/controlled-input.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/controlled-input.expect.md index ca5596a767..13c16778cb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/controlled-input.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/controlled-input.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md index 750f670d43..a9cbc1a4ce 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/delete-computed-property.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/delete-property.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/delete-property.expect.md index e42e0a2ea6..6676792258 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/delete-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/delete-property.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md index d7f30200b0..a3c0d6d8f2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/dependencies-outputs.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/dependencies.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/dependencies.expect.md index 6ad952df97..25ccdf3161 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/dependencies.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/dependencies.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md index 502f862674..be63b35b73 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructure-capture-global.expect.md @@ -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) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md index b3ac9c22e7..b0790c1954 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-array-default.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md index 05f3d05c85..ec378ebdc5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment-array-default.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md index a51ed1a139..f903a00b3d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-assignment.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md index 6cf9c2eaab..4ca7ac76b1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructuring-object-default.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/destructuring.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/destructuring.expect.md index e5e8f46d44..c9a6bec1a2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/destructuring.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/destructuring.expect.md @@ -27,9 +27,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(18); + const $ = useMemoCache(18); const c_0 = $[0] !== a; let t0; let d; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md index ed170bd12c..9de75ae988 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/do-while-compound-test.expect.md @@ -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 c_0 = $[0] !== props; let ret; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md index 9a30e4b579..857d4dbdbe 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/do-while-conditional-break.expect.md @@ -18,9 +18,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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/do-while-continue.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/do-while-continue.expect.md index a50fbd678e..b307020c4d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/do-while-continue.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/do-while-continue.expect.md @@ -21,9 +21,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 ret; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const x = [0, 1, 2, 3]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/do-while-early-unconditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/do-while-early-unconditional-break.expect.md index a6aa7484ff..3e6d86f6fe 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/do-while-early-unconditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/do-while-early-unconditional-break.expect.md @@ -16,9 +16,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 = [1, 2, 3]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/do-while-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/do-while-simple.expect.md index fb170983c6..402a072e4b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/do-while-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/do-while-simple.expect.md @@ -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 ret; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const x = [1, 2, 3]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/error.file-has-non-critical-errors.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/error.file-has-non-critical-errors.expect.md index 0dbe427c7d..c9988f4024 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/error.file-has-non-critical-errors.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/error.file-has-non-critical-errors.expect.md @@ -18,14 +18,14 @@ function Good() { ## Code ```javascript -import * as React from "react"; // @panicOnBailout false +import { unstable_useMemoCache as useMemoCache } from "react"; // @panicOnBailout false function Bad() { var x = 1; return
{x}
; } function Good() { - const $ = React.unstable_useMemoCache(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 =
{1}
; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md index b0356b54b4..04635d084c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-destructured-rest-element.expect.md @@ -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(7); + const $ = useMemoCache(7); const c_0 = $[0] !== props.a; let b; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md index 37739c7713..7148baeca0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-jsx-child.expect.md @@ -19,9 +19,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(9); + const $ = useMemoCache(9); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md index ebb585cacd..83f0a3483c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-logical.expect.md @@ -16,9 +16,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(10); + const $ = useMemoCache(10); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md index 9091012fa0..80c9b4d3bc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-dependency.expect.md @@ -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(5); + const $ = useMemoCache(5); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md index f9ea49ba9b..dfd2158551 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-allocating-nested-dependency.expect.md @@ -32,9 +32,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; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md index 6f1b6a58b7..78c591f836 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/escape-analysis-non-escaping-interleaved-primitive-dependency.expect.md @@ -25,9 +25,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 a = props.a + props.b; const c_0 = $[0] !== a; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md index 9152dc9414..4e044f0571 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/extend-scopes-if.expect.md @@ -22,9 +22,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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md index 9b93f378d4..8e3d82f3d8 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/fbt-call-complex-param-value.expect.md @@ -17,11 +17,11 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; import fbt from "fbt"; function Component(props) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.name; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/fbt-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/fbt-call.expect.md index f95ffb176e..2a431b6a61 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/fbt-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/fbt-call.expect.md @@ -17,11 +17,11 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; import fbt from "fbt"; function Component(props) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.count; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md index d5e9f09586..400fb92d33 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/fbt-params-complex-param-value.expect.md @@ -17,11 +17,11 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; import fbt from "fbt"; function Component(props) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.name; let t1; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/fbt-params.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/fbt-params.expect.md index 730880cf05..d4c12b7579 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/fbt-params.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/fbt-params.expect.md @@ -17,11 +17,11 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; import fbt from "fbt"; function Component(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.name; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-break.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-break.expect.md index 3ad0d1aa70..780bff7a89 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-break.expect.md @@ -15,9 +15,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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-conditional-break.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-conditional-break.expect.md index f088ecc258..12d43b90e0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-conditional-break.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-conditional-break.expect.md @@ -18,9 +18,9 @@ function Component() { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function Component() { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-continue.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-continue.expect.md index 879d38c582..b8dde87579 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-continue.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-continue.expect.md @@ -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(2); + const $ = useMemoCache(2); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = [0, 1, 2, 3]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-destructure.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-destructure.expect.md index fac92414f0..4ce2e30843 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-destructure.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-destructure.expect.md @@ -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(1); + const $ = useMemoCache(1); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-mutate.expect.md index 31461555a7..412f474e84 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-mutate.expect.md @@ -16,9 +16,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 results; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const collection = [makeObject()]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/for-of-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/for-of-simple.expect.md index a6e68f753f..65b917f291 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/for-of-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/for-of-simple.expect.md @@ -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(1); + const $ = useMemoCache(1); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md index b0d1155d7b..b1a6d552f2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/frozen-after-alias.expect.md @@ -18,9 +18,9 @@ function foo(x) {} ## 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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-reassign.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-reassign.expect.md index 499cf8d208..4f6e8a4da0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-reassign.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-reassign.expect.md @@ -15,9 +15,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 = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-redeclare.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-redeclare.expect.md index 7dbf83bfe7..e565bd0cb2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-redeclare.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-redeclare.expect.md @@ -15,9 +15,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 = function x() {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md index e8f13f257d..1cfe84085f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/function-declaration-simple.expect.md @@ -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(3); + const $ = useMemoCache(3); const c_0 = $[0] !== a; let t; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md index bc07c95699..7b9e6293ca 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/function-param-assignment-pattern.expect.md @@ -11,9 +11,9 @@ function Component(x = "default", y = [{}]) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function Component(t24, t0) { - const $ = React.unstable_useMemoCache(5); + const $ = useMemoCache(5); const x = t24 === undefined ? "default" : t24; const c_0 = $[0] !== t0; let t1; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md index 517ee00188..d81cd38c4a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-default-function.expect.md @@ -23,13 +23,13 @@ function Foo(props) { ```javascript import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; -import * as React from "react"; // @gating @forgetDirective +import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @forgetDirective function Bar_uncompiled(props) { "use forget"; return
{props.bar}
; } function Bar_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { @@ -53,7 +53,7 @@ function Foo_uncompiled(props) { return {props.bar}; } function Foo_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md index 0973812619..507118564b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function-and-default.expect.md @@ -23,13 +23,13 @@ export function Foo(props) { ```javascript import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; -import * as React from "react"; // @gating @forgetDirective +import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @forgetDirective function Bar_uncompiled(props) { "use forget"; return
{props.bar}
; } function Bar_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { @@ -53,7 +53,7 @@ function Foo_uncompiled(props) { return {props.bar}; } function Foo_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md index 5e01f917e6..f2e7b339d6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/gating-test-export-function.expect.md @@ -23,13 +23,13 @@ export function Foo(props) { ```javascript import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; -import * as React from "react"; // @gating @forgetDirective +import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @forgetDirective function Bar_uncompiled(props) { "use forget"; return
{props.bar}
; } function Bar_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { @@ -52,7 +52,7 @@ function Foo_uncompiled(props) { return {props.bar}; } function Foo_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/gating-test.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/gating-test.expect.md index 9bed203aa1..1bf96de170 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/gating-test.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/gating-test.expect.md @@ -23,13 +23,13 @@ function Foo(props) { ```javascript import { isForgetEnabled_Fixtures } from "ReactForgetFeatureFlag"; -import * as React from "react"; // @gating @forgetDirective +import { unstable_useMemoCache as useMemoCache } from "react"; // @gating @forgetDirective function Bar_uncompiled(props) { "use forget"; return
{props.bar}
; } function Bar_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { @@ -52,7 +52,7 @@ function Foo_uncompiled(props) { return {props.bar}; } function Foo_forget(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md index 96a01b7347..b37d1d8c4b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hook-call.expect.md @@ -22,12 +22,12 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function useFreeze() {} function foo() {} function Component(props) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md index 742c756353..de039f2ba6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-arguments.expect.md @@ -18,9 +18,9 @@ function call(x) {} ## 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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md index 46758fa2f2..58f4d87fc9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/hooks-freeze-possibly-mutable-arguments.expect.md @@ -25,9 +25,9 @@ function call(x) {} ## 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); const cond = props.cond; const x = props.x; let a = undefined; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md index 493ca50b49..da12a92d08 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/inadvertent-mutability-readonly-lambda.expect.md @@ -21,9 +21,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 [value, setValue] = useState(null); const c_0 = $[0] !== setValue; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md index bf33e6b5bf..9e78cf11ca 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/independent-across-if.expect.md @@ -36,7 +36,7 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function compute() {} function mutate() {} function foo() {} @@ -57,7 +57,7 @@ function Foo() {} * return = */ function Component(props) { - const $ = React.unstable_useMemoCache(8); + const $ = useMemoCache(8); const c_0 = $[0] !== props.a; const c_1 = $[1] !== props.b; const c_2 = $[2] !== props.c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md index 1d6b4fe15d..44f64ad0b5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/independent.expect.md @@ -27,7 +27,7 @@ function Foo() {} ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; /** * Should produce 3 scopes: * @@ -39,7 +39,7 @@ import * as React from "react"; * return = */ function Component(props) { - const $ = React.unstable_useMemoCache(7); + const $ = useMemoCache(7); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md index fba0659181..1cc8e18228 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/independently-memoize-object-property.expect.md @@ -15,9 +15,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(7); + const $ = useMemoCache(7); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md index 3f5a66b42e..f69e8eac44 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/infer-global-object.expect.md @@ -21,10 +21,10 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; // Check that we correctly resolve type and effect lookups on the javascript +import { unstable_useMemoCache as useMemoCache } from "react"; // Check that we correctly resolve type and effect lookups on the javascript // global object. function Component(props) { - const $ = React.unstable_useMemoCache(7); + const $ = useMemoCache(7); const c_0 = $[0] !== props.b; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md index 5449ffe010..253483f765 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-dynamic.expect.md @@ -22,9 +22,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(23); + const $ = useMemoCache(23); const item = useFragment(FRAGMENT, props.item); useFreeze(item); const c_0 = $[0] !== item; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md index ea89b86a49..3981985063 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/inner-memo-value-not-promoted-to-outer-scope-static.expect.md @@ -19,9 +19,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(12); + const $ = useMemoCache(12); let t1; let t2; let t3; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md index eb58aca30f..322965a4aa 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/interdependent-across-if.expect.md @@ -30,7 +30,7 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function compute() {} function foo() {} function Foo() {} @@ -46,7 +46,7 @@ function Foo() {} * return = */ function Component(props) { - const $ = React.unstable_useMemoCache(8); + const $ = useMemoCache(8); const c_0 = $[0] !== props.a; const c_1 = $[1] !== props.b; const c_2 = $[2] !== props.c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md index f909625a97..13f481ad4b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/interdependent.expect.md @@ -27,7 +27,7 @@ function Foo() {} ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; /** * Should produce 1 scope: * @@ -38,7 +38,7 @@ import * as React from "react"; * return = */ function Component(props) { - const $ = React.unstable_useMemoCache(7); + const $ = useMemoCache(7); const c_0 = $[0] !== props.a; const c_1 = $[1] !== props.b; let a; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/inverted-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/inverted-if.expect.md index 4bd8da96f3..e3b16d7f6e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/inverted-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/inverted-if.expect.md @@ -19,9 +19,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(5); + const $ = useMemoCache(5); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/issue933-disjoint-set-infinite-loop.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/issue933-disjoint-set-infinite-loop.expect.md index bbd5541b4e..24783b9fb6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/issue933-disjoint-set-infinite-loop.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/issue933-disjoint-set-infinite-loop.expect.md @@ -16,9 +16,9 @@ function MyApp(props) { ## Code ```javascript -import * as React from "react"; // This caused an infinite loop in the compiler +import { unstable_useMemoCache as useMemoCache } from "react"; // This caused an infinite loop in the compiler function MyApp(props) { - const $ = React.unstable_useMemoCache(1); + const $ = useMemoCache(1); let y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { y = makeObj(); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md index 4d38204522..df299d5f62 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-empty-expression.expect.md @@ -16,9 +16,9 @@ export function Component(props) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; export function Component(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md index 074be553d2..a7d1bb3ce4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-fragment.expect.md @@ -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(4); + const $ = useMemoCache(4); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = <>Text; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-member-expression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-member-expression.expect.md index 9da02cb91f..5064c05324 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-member-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-member-expression.expect.md @@ -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); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = ; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md index 5a41b1481f..638fdcb4ba 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-namespaced-name.expect.md @@ -11,9 +11,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.version; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md index 933217b9be..27b813adf3 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-spread.expect.md @@ -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(5); + const $ = useMemoCache(5); const t0 = props.cond ? props.foo : props.bar; const c_0 = $[0] !== t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md index 01e001bd57..49d7467cfb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order-non-global.expect.md @@ -21,9 +21,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(13); + const $ = useMemoCache(13); const c_0 = $[0] !== props.component; const c_1 = $[1] !== props.alternateComponent; let Tag; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md index 10ec0f6869..1aaa9e0419 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/jsx-tag-evaluation-order.expect.md @@ -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(3); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = ; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md index 2a30363728..8c0a5d7287 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/lambda-capture-returned-alias.expect.md @@ -26,14 +26,14 @@ function CaptureNotMutate(props) { ## Code ```javascript -import * as React from "react"; // Here, element should not be memoized independently of aliasedElement, since +import { unstable_useMemoCache as useMemoCache } from "react"; // Here, element should not be memoized independently of aliasedElement, since // it is captured by fn. // AnalyzeFunctions currently does not find captured objects. // - mutated context refs are declared as `Capture` effect in `FunctionExpression.deps` // - all other context refs are left as Unknown. InferReferenceEffects currently demotes // them to reads function CaptureNotMutate(props) { - const $ = React.unstable_useMemoCache(5); + const $ = useMemoCache(5); const c_0 = $[0] !== props.x; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md index adfd9c71ac..f023e622bf 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/lambda-mutate-shadowed-object.expect.md @@ -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 = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md index d3d55a2fcf..fd901bae11 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/logical-expression-object.expect.md @@ -18,9 +18,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 a = props.a || (props.b && props.c && props.d); const b = (props.a && props.b && props.c) || props.d; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md index 2f975e6f34..50342f1df7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/method-call-computed.expect.md @@ -21,9 +21,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(8); + const $ = useMemoCache(8); const c_0 = $[0] !== a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md index 1b35ebc16c..54a8196e43 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/method-call-fn-call.expect.md @@ -18,9 +18,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(6); + const $ = useMemoCache(6); const c_0 = $[0] !== a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/method-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/method-call.expect.md index 09363f2563..07060f215a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/method-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/method-call.expect.md @@ -17,9 +17,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 c_0 = $[0] !== a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md index 129b37fa79..57d1efeb4c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-export-gating-test.expect.md @@ -18,12 +18,12 @@ export const Renderer = (props) => ( ```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 ; } function ErrorView_forget(error, _retry) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== error; let t0; if (c_0) { @@ -47,7 +47,7 @@ function Renderer_uncompiled(props) { ); } function Renderer_forget(props) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = ; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md index e312f2795b..7d05e66dd6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/multi-arrow-expr-gating-test.expect.md @@ -20,12 +20,12 @@ export default Renderer; ```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 ; } function ErrorView_forget(error, _retry) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== error; let t0; if (c_0) { @@ -49,7 +49,7 @@ function Renderer_uncompiled(props) { ); } function Renderer_forget(props) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = ; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md index 3806f1d525..31deb29cfe 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/nested-function-shadowed-identifiers.expect.md @@ -18,9 +18,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(5); + const $ = useMemoCache(5); const [x, setX] = useState(null); const c_0 = $[0] !== setX; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md index 7ca8997d51..f7ae049619 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/nested-optional-member-expr.expect.md @@ -14,10 +14,10 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; // We should codegen nested optional properties correctly +import { unstable_useMemoCache as useMemoCache } from "react"; // We should codegen nested optional properties correctly // (i.e. placing `?` in the correct PropertyLoad) function Component(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/new-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/new-spread.expect.md index c2e8422ec1..a843ce474b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/new-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/new-spread.expect.md @@ -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.bar; const c_1 = $[1] !== props.foo; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md index 7ead133179..76d7a0a32f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-cached-in-if-else.expect.md @@ -18,9 +18,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); let x = undefined; if (someVal) { const c_0 = $[0] !== b; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md index 7613cf74eb..0ef5da016e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/obj-literal-mutated-after-if-else.expect.md @@ -19,9 +19,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== b; const c_1 = $[1] !== c; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md index 678d09baea..ca446c79b2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else-with-alias.expect.md @@ -21,9 +21,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); someObj(); const c_0 = $[0] !== a; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md index fa3f8336c6..b3c728dbcb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-if-else.expect.md @@ -19,9 +19,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); someObj(); const c_0 = $[0] !== a; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md index 180c7ec1a7..b407146529 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/obj-mutated-after-nested-if-else-with-alias.expect.md @@ -27,9 +27,9 @@ function foo(a, b, c, d) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a, b, c, d) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); someObj(); const c_0 = $[0] !== a; const c_1 = $[1] !== b; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md index 3c960165ac..fb9a5dcadb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/object-expression-string-literal-key.expect.md @@ -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 c_0 = $[0] !== props.foo; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md index d86f47801b..939686b98a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/object-literal-spread-element.expect.md @@ -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 c_0 = $[0] !== props.foo; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md index 460abcdfbb..79623bf40f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/object-pattern-params.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md index dd2a906415..d22f1efc61 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-call-with-independently-memoizable-arg.expect.md @@ -21,9 +21,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; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-call.expect.md index 9dc9b8ae64..5441290961 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-call.expect.md @@ -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(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md index b258ca1fc2..aa66026c93 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-member-expression-chain.expect.md @@ -15,10 +15,10 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; // Note that `a?.b.c` is semantically different from `(a?.b).c` +import { unstable_useMemoCache as useMemoCache } from "react"; // Note that `a?.b.c` is semantically different from `(a?.b).c` // We should codegen the correct member expressions function Component(props) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const x = props?.b.c; const y = props?.b.c.d?.e.f.g?.h; const c_0 = $[0] !== x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md index 2e17827187..507c4f0775 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-method-call.expect.md @@ -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(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md index 89687e7588..5aac758203 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-method-call.expect.md @@ -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(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md index 28f4e08c9c..cb6b417337 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/optional-receiver-optional-method.expect.md @@ -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(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md index 01eee05f54..73289d9e4f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-shadowing-within-block.expect.md @@ -20,9 +20,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(9); + const $ = useMemoCache(9); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md index 761862be81..559149ff7b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/overlapping-scopes-within-block.expect.md @@ -20,9 +20,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(7); + const $ = useMemoCache(7); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md index 2f57607737..8446f81dfb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep-nested-scope.expect.md @@ -20,13 +20,13 @@ function PrimitiveAsDepNested(props) { ## Code ```javascript -import * as React from "react"; // props.b + 1 is an non-allocating expression, which means Forget can +import { unstable_useMemoCache as useMemoCache } from "react"; // props.b + 1 is an non-allocating expression, which means Forget can // emit it trivially and repeatedly (e.g. no need to memoize props.b + 1 // separately from props.b) // Correctness: // y depends on either props.b or props.b + 1 function PrimitiveAsDepNested(props) { - const $ = React.unstable_useMemoCache(9); + const $ = useMemoCache(9); const c_0 = $[0] !== props.b; const c_1 = $[1] !== props.a; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md index ded08e9750..119e5d0d7f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/primitive-as-dep.expect.md @@ -17,13 +17,13 @@ function PrimitiveAsDep(props) { ## Code ```javascript -import * as React from "react"; // props.b + 1 is an non-allocating expression, which means Forget can +import { unstable_useMemoCache as useMemoCache } from "react"; // props.b + 1 is an non-allocating expression, which means Forget can // emit it trivially and repeatedly (e.g. no need to memoize props.b + 1 // separately from props.b) // Correctness: // y depends on either props.b or props.b + 1 function PrimitiveAsDep(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const t0 = props.b + 1; const c_0 = $[0] !== t0; let t1; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md index 1688d69f4b..aad034ab9f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/prop-capturing-function-1.expect.md @@ -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(5); + const $ = useMemoCache(5); const c_0 = $[0] !== a; const c_1 = $[1] !== b; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/property-assignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/property-assignment.expect.md index 217d0d1e41..eecc8d3e36 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/property-assignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/property-assignment.expect.md @@ -16,9 +16,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.p0; let x; let child; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md index 7f7b201706..91a98f6487 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/property-call-spread.expect.md @@ -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; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scope-grouping.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scope-grouping.expect.md index 1e7f65abce..87a95882dc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scope-grouping.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scope-grouping.expect.md @@ -17,9 +17,9 @@ function foo() { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo() { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md index a9ce7259f0..7262aa6cf5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes-if.expect.md @@ -19,9 +19,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(8); + const $ = useMemoCache(8); const c_0 = $[0] !== a; const c_1 = $[1] !== b; const c_2 = $[2] !== c; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md index 3cda673f77..e25b01d7e6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactive-scopes.expect.md @@ -18,9 +18,9 @@ function f(a, b) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function f(a, b) { - const $ = React.unstable_useMemoCache(5); + const $ = useMemoCache(5); const c_0 = $[0] !== a.length; const c_1 = $[1] !== b; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md index f1fb7621f9..d3505a8629 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-interleaved-reactivity.expect.md @@ -27,9 +27,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.b; let a; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md index 981553341e..8f6a59fb01 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-computed-load.expect.md @@ -16,9 +16,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 c_0 = $[0] !== props.key; const c_1 = $[1] !== props.a; let items; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md index 9ca41ccdf4..0bb54683ce 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reactivity-analysis-reactive-via-mutation-of-property-load.expect.md @@ -16,9 +16,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; let items; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reassigned-temporary-accessed-outside-scope.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reassigned-temporary-accessed-outside-scope.expect.md index 4f8ecbcb72..9b32847042 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reassigned-temporary-accessed-outside-scope.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reassigned-temporary-accessed-outside-scope.expect.md @@ -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(6); + const $ = useMemoCache(6); const c_0 = $[0] !== props.value; let t0; let t1; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md index d1af434ae2..848e3f6164 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reassignment-conditional.expect.md @@ -21,9 +21,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(9); + const $ = useMemoCache(9); const c_0 = $[0] !== props.p0; const c_1 = $[1] !== props.p1; const c_2 = $[2] !== props.p2; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md index f62558fe3a..5b73d827f6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reassignment-separate-scopes.expect.md @@ -33,9 +33,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(11); + const $ = useMemoCache(11); const c_0 = $[0] !== a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reassignment.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reassignment.expect.md index 29c6c6cece..772438d0ef 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reassignment.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reassignment.expect.md @@ -20,9 +20,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 c_0 = $[0] !== props.p0; const c_1 = $[1] !== props.p1; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md index 3e1e41e1db..fc8c2448b3 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-condexpr.expect.md @@ -16,12 +16,12 @@ function TestCondDepInConditionalExpr(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should be added as a unconditional dependency to the reactive // scope that produces x, since it is accessed unconditionally in all cfg // paths function TestCondDepInConditionalExpr(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a.b; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md index fab38ac206..99edb89072 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-ifelse.expect.md @@ -21,12 +21,12 @@ function TestCondDepInDirectIfElse(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should be added as a unconditional dependency to the reactive // scope that produces x, since it is accessed unconditionally in all cfg // paths function TestCondDepInDirectIfElse(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a.b; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md index 323908a5e5..f7d1b7006d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse-missing.expect.md @@ -22,11 +22,11 @@ function TestCondDepInNestedIfElse(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive // scope that produces x if it is not accessed in every path function TestCondDepInNestedIfElse(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md index c9df7941b2..4e2512d24b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-nested-ifelse.expect.md @@ -27,12 +27,12 @@ function TestCondDepInNestedIfElse(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should be added as a unconditional dependency to the reactive // scope that produces x, since it is accessed unconditionally in all cfg // paths function TestCondDepInNestedIfElse(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a.b; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md index 8aef4e4809..16c4e7d234 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-case.expect.md @@ -26,11 +26,11 @@ function TestCondDepInSwitchMissingCase(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive // scope that produces x if it is not accessed in every path function TestCondDepInSwitchMissingCase(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md index 634628bf27..27d0f2dea8 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch-missing-default.expect.md @@ -23,11 +23,11 @@ function TestCondDepInSwitchMissingDefault(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should NOT be added as a unconditional dependency to the reactive // scope that produces x if it is not accessed in the default case. function TestCondDepInSwitchMissingDefault(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md index 04d5bf0a4a..340c06f116 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-cfg-switch.expect.md @@ -26,12 +26,12 @@ function TestCondDepInSwitch(props, other) { ## Code ```javascript -import * as React from "react"; // props.a.b should be added as a unconditional dependency to the reactive +import { unstable_useMemoCache as useMemoCache } from "react"; // props.a.b should be added as a unconditional dependency to the reactive // scope that produces x, since it is accessed unconditionally in all cfg // paths function TestCondDepInSwitch(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a.b; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md index a38bfc48a5..9ccab0e33d 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-no-uncond.expect.md @@ -18,10 +18,10 @@ function TestOnlyConditionalDependencies(props, other) { ## Code ```javascript -import * as React from "react"; // When an object's properties are only read conditionally, we should +import { unstable_useMemoCache as useMemoCache } from "react"; // When an object's properties are only read conditionally, we should // track the base object as a dependency. function TestOnlyConditionalDependencies(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md index d39ae74790..77d25c6bd5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-promote-uncond.expect.md @@ -19,11 +19,11 @@ function TestPromoteUnconditionalAccessToDependency(props, other) { ## Code ```javascript -import * as React from "react"; // When a conditional dependency `props.a.b.c` has no unconditional dependency +import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditional dependency `props.a.b.c` has no unconditional dependency // in its subpath or superpath, we should find the nearest unconditional access // and promote it to an unconditional dependency. function TestPromoteUnconditionalAccessToDependency(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== props.a; const c_1 = $[1] !== other; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md index b2b66aa18a..c9361ceab1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order1.expect.md @@ -21,13 +21,13 @@ function TestConditionalSubpath1(props, other) { ## Code ```javascript -import * as React from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional +import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional // dependency `props.a.b`, we can access `props.a` while preserving program // semantics (with respect to nullthrows). // deps: {`props.a`, `props.a.b`} can further reduce to just `props.a` // ordering of accesses should not matter function TestConditionalSubpath1(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== props.a; const c_1 = $[1] !== other; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md index 2cd8089bd9..3fd5902b4c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-subpath-order2.expect.md @@ -21,13 +21,13 @@ function TestConditionalSubpath2(props, other) { ## Code ```javascript -import * as React from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional +import { unstable_useMemoCache as useMemoCache } from "react"; // When a conditional dependency `props.a` is a subpath of an unconditional // dependency `props.a.b`, we can access `props.a` while preserving program // semantics (with respect to nullthrows). // deps: {`props.a`, `props.a.b`} can further reduce to just `props.a` // ordering of accesses should not matter function TestConditionalSubpath2(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md index 3405d9edec..bab501642a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order1.expect.md @@ -20,12 +20,12 @@ function TestConditionalSuperpath1(props, other) { ## Code ```javascript -import * as React from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional +import { unstable_useMemoCache as useMemoCache } from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional // dependency `props.a.b`, we can safely overestimate and only track `props.a` // as a dependency // ordering of accesses should not matter function TestConditionalSuperpath1(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== props.a; const c_1 = $[1] !== other; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md index 07a604365d..5f23bdfbbb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-deps-superpath-order2.expect.md @@ -20,12 +20,12 @@ function TestConditionalSuperpath2(props, other) { ## Code ```javascript -import * as React from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional +import { unstable_useMemoCache as useMemoCache } from "react"; // When an unconditional dependency `props.a` is the subpath of a conditional // dependency `props.a.b`, we can safely overestimate and only track `props.a` // as a dependency // ordering of accesses should not matter function TestConditionalSuperpath2(props, other) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== other; const c_1 = $[1] !== props.a; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md index 534a58f34a..46988d773f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-cond-memberexpr-join.expect.md @@ -25,7 +25,7 @@ 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.b` or a subpath as a dependency. // // (1) Since the reactive block producing x unconditionally read props.a.<...>, @@ -37,7 +37,7 @@ import * as React from "react"; // To preserve the nullthrows behavior and react // we technically do not need to add `props.a` as a dependency. function Component(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a.b; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md index 31dadfc484..a381370143 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-cond-scope.expect.md @@ -34,7 +34,7 @@ function TestReactiveDepsInCondScope(props) { ## Code ```javascript -import * as React from "react"; // Some reactive scopes are created within a conditional. If a child scope +import { unstable_useMemoCache as useMemoCache } from "react"; // Some reactive scopes are created within a conditional. If a child scope // is within a conditional, its reactive dependencies should be propagated // as conditionals // @@ -53,7 +53,7 @@ import * as React from "react"; // Some reactive scopes are created within a con // ``` function TestReactiveDepsInCondScope(props) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md index 76e3f89f03..813cdbf5c4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-deps-join-uncond-scopes-cond-deps.expect.md @@ -34,7 +34,7 @@ function TestJoinCondDepsInUncondScopes(props) { ## Code ```javascript -import * as React from "react"; // This tests an optimization, NOT a correctness property. +import { unstable_useMemoCache as useMemoCache } from "react"; // This tests an optimization, NOT a correctness property. // When propagating reactive dependencies of an inner scope up to its parent, // we prefer to retain granularity. // @@ -52,7 +52,7 @@ import * as React from "react"; // This tests an optimization, NOT a correctness // } function TestJoinCondDepsInUncondScopes(props) { - const $ = React.unstable_useMemoCache(8); + const $ = useMemoCache(8); const c_0 = $[0] !== props.a.b; let x; let y; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md index c29d39b663..fd564a5ad0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-descendant.expect.md @@ -17,10 +17,10 @@ function TestNonOverlappingDescendantTracked(props) { ## Code ```javascript -import * as React from "react"; // Test that we can track non-overlapping dependencies separately. +import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we can track non-overlapping dependencies separately. // (not needed for correctness but for dependency granularity) function TestNonOverlappingDescendantTracked(props) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.a.x.y; const c_1 = $[1] !== props.a.c.x.y.z; const c_2 = $[2] !== props.b; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md index 7763fcf6bc..66a2fb7923 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-nonoverlap-direct.expect.md @@ -16,10 +16,10 @@ function TestNonOverlappingTracked(props) { ## Code ```javascript -import * as React from "react"; // Test that we can track non-overlapping dependencies separately. +import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we can track non-overlapping dependencies separately. // (not needed for correctness but for dependency granularity) function TestNonOverlappingTracked(props) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== props.a.b; const c_1 = $[1] !== props.a.c; let x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md index 0bfbb52eac..c1c689c6c5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-descendant.expect.md @@ -17,10 +17,10 @@ function TestOverlappingDescendantTracked(props) { ## Code ```javascript -import * as React from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as +import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as // a dependency function TestOverlappingDescendantTracked(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md index 8b6f408ffb..dc7443ca01 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-overlap-direct.expect.md @@ -17,10 +17,10 @@ function TestOverlappingTracked(props) { ## Code ```javascript -import * as React from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as +import { unstable_useMemoCache as useMemoCache } from "react"; // Test that we correctly track a subpath if the subpath itself is accessed as // a dependency function TestOverlappingTracked(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md index 9c12bfc203..a4ddfc2337 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order1.expect.md @@ -17,10 +17,10 @@ function TestDepsSubpathOrder1(props) { ## Code ```javascript -import * as React from "react"; // Determine that we only need to track p.a here +import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that we only need to track p.a here // Ordering of access should not matter function TestDepsSubpathOrder1(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md index e04e585cfb..16260277e7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order2.expect.md @@ -17,10 +17,10 @@ function TestDepsSubpathOrder2(props) { ## Code ```javascript -import * as React from "react"; // Determine that we only need to track p.a here +import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that we only need to track p.a here // Ordering of access should not matter function TestDepsSubpathOrder2(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md index c7da987d15..16486d7bc2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/reduce-reactive-uncond-deps-subpath-order3.expect.md @@ -17,10 +17,10 @@ function TestDepsSubpathOrder3(props) { ## Code ```javascript -import * as React from "react"; // Determine that we only need to track p.a here +import { unstable_useMemoCache as useMemoCache } from "react"; // Determine that we only need to track p.a here // Ordering of access should not matter function TestDepsSubpathOrder3(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md index a839f242be..8d84236c61 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/regexp-literal.expect.md @@ -18,9 +18,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); let t0; let value; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md index e8c55c23a0..3c18ae6c23 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare-maybe-frozen.expect.md @@ -43,10 +43,10 @@ function foo(props) { ## Code ```javascript -import * as React from "react"; // note: comments are for the ideal scopes, not what is currently +import { unstable_useMemoCache as useMemoCache } from "react"; // note: comments are for the ideal scopes, not what is currently // emitted function foo(props) { - const $ = React.unstable_useMemoCache(16); + const $ = useMemoCache(16); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md index ed72505eb9..38bccac377 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/same-variable-as-dep-and-redeclare.expect.md @@ -43,10 +43,10 @@ function foo(props) { ## Code ```javascript -import * as React from "react"; // note: comments are for the ideal scopes, not what is currently +import { unstable_useMemoCache as useMemoCache } from "react"; // note: comments are for the ideal scopes, not what is currently // emitted function foo(props) { - const $ = React.unstable_useMemoCache(15); + const $ = useMemoCache(15); const c_0 = $[0] !== props.a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md index b13e55e420..6bfd0623f5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/sequence-expression.expect.md @@ -17,9 +17,9 @@ function foo() {} ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function sequence(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); Math.max(1, 2); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md index dc833fd3db..932bb2436c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/simple-alias.expect.md @@ -19,10 +19,10 @@ function foo() { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function mutate() {} function foo() { - const $ = React.unstable_useMemoCache(1); + const $ = useMemoCache(1); let c; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { let b = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/simple-function-1.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/simple-function-1.expect.md index d60a518544..ae557115da 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/simple-function-1.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/simple-function-1.expect.md @@ -14,9 +14,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 = function (a) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/simple-scope.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/simple-scope.expect.md index 0d486e4ee7..63338fc480 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/simple-scope.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/simple-scope.expect.md @@ -12,9 +12,9 @@ function foo(a) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== a.b; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/simple.expect.md index 828ff01bef..897efa572f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/simple.expect.md @@ -14,9 +14,9 @@ export default function foo(x, y) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; export default function foo(x, y) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); if (x) { const c_0 = $[0] !== y; let t0; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-arrayexpression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-arrayexpression.expect.md index b1751e3675..26161686a0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-arrayexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-arrayexpression.expect.md @@ -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(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = [1, 2]; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md index 13eb752b92..44f498f11e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx-2.expect.md @@ -21,11 +21,11 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; // @Pass runMutableRangeAnalysis +import { unstable_useMemoCache as useMemoCache } from "react"; // @Pass runMutableRangeAnalysis 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")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md index c4511530f1..9839de7e27 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-call-jsx.expect.md @@ -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")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md index 62567583de..efbe528b59 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-cascading-eliminated-phis.expect.md @@ -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(2); + const $ = useMemoCache(2); let x = 0; const c_0 = $[0] !== props; let values; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-for-of.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-for-of.expect.md index 80ebf01701..ce8a164a9a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-for-of.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-for-of.expect.md @@ -18,9 +18,9 @@ function foo(cond) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(cond) { - const $ = React.unstable_useMemoCache(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md index b279138a58..17506f2c49 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-leave-case.expect.md @@ -22,9 +22,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 x; let y; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md index 5a05f82b8d..0b469af460 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-newexpression.expect.md @@ -16,11 +16,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(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const a = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-non-empty-initializer.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-non-empty-initializer.expect.md index 7039b5fc93..da8db4321b 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-non-empty-initializer.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-non-empty-initializer.expect.md @@ -17,9 +17,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(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression-phi.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression-phi.expect.md index cc18aa68c7..a87fe7e267 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression-phi.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression-phi.expect.md @@ -21,9 +21,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); const x = 1; const y = 3; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression.expect.md index 1882cfd83a..ac80b9b4ba 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-objectexpression.expect.md @@ -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(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = { a: 1, b: 2 }; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md index d962fd188a..7d82e07f26 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-alias-mutate-if.expect.md @@ -21,9 +21,9 @@ function foo(a) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md index e6b72040b6..1e759237f2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-if.expect.md @@ -19,9 +19,9 @@ function foo(a) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a) { - const $ = React.unstable_useMemoCache(4); + const $ = useMemoCache(4); const c_0 = $[0] !== a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md index 218ae7812c..78795df329 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-if.expect.md @@ -20,9 +20,9 @@ function foo(a) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md index c3e93b763d..b54f2ba730 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate-inside-if.expect.md @@ -20,9 +20,9 @@ function foo(a) { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function foo(a) { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); const c_0 = $[0] !== a; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md index ede749c008..e20ffb6624 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-alias-mutate.expect.md @@ -18,9 +18,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 y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const a = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-call.expect.md index 6ba201aeda..ef3d869bde 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-call.expect.md @@ -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(1); + const $ = useMemoCache(1); let y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-2.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-2.expect.md index f0fabe4067..e72a531877 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-2.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-2.expect.md @@ -15,9 +15,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 y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-alias.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-alias.expect.md index 4a68961841..1b78e69fb2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-alias.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate-alias.expect.md @@ -18,9 +18,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 y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const a = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate.expect.md index 031470cd5b..ff5216169c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property-mutate.expect.md @@ -15,9 +15,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 y; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { const x = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property.expect.md index 466a42b7a5..27f8da6d40 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-property.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-property.expect.md @@ -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 = []; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-reassign-in-rval.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-reassign-in-rval.expect.md index 6b167dd54d..088b4db75c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-reassign-in-rval.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-reassign-in-rval.expect.md @@ -14,9 +14,9 @@ function Component() { ## Code ```javascript -import * as React from "react"; // Forget should call the original x (x = foo()) to compute result +import { unstable_useMemoCache as useMemoCache } from "react"; // Forget should call the original x (x = foo()) to compute result function Component() { - const $ = React.unstable_useMemoCache(3); + const $ = useMemoCache(3); let t0; let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md index b0a33716fe..a477588511 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction-with-mutation.expect.md @@ -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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md index 4c72f86785..5b7fe68b16 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-destruction.expect.md @@ -17,9 +17,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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.bar; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md index ab8bb979e2..513f81aab6 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary-with-mutation.expect.md @@ -16,9 +16,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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md index 0581295809..4d9a788eb7 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-ternary.expect.md @@ -15,9 +15,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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.bar; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md index 8062cc74df..f3537e619a 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary-with-mutation.expect.md @@ -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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md index ea0a6e6c95..98cd976145 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-ternary.expect.md @@ -17,9 +17,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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.bar; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md index cfca44dd5c..2e37ce97fd 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-unconditional-with-mutation.expect.md @@ -23,9 +23,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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md index 943461ecda..f98c37a237 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring-with-mutation.expect.md @@ -19,9 +19,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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md index 6648f30cc5..1e650f5a51 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-via-destructuring.expect.md @@ -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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.bar; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md index 3212056dd9..a12689c891 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming-with-mutation.expect.md @@ -19,9 +19,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; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md index f97e463a39..01b46b3565 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/ssa-renaming.expect.md @@ -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(4); + const $ = useMemoCache(4); const c_0 = $[0] !== props.bar; let x; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/store-via-call.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/store-via-call.expect.md index 86507deeb0..07998b987c 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/store-via-call.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/store-via-call.expect.md @@ -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(1); + const $ = useMemoCache(1); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/store-via-new.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/store-via-new.expect.md index 8a540e1a59..eb62c97822 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/store-via-new.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/store-via-new.expect.md @@ -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(1); + const $ = useMemoCache(1); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md index 57af863674..2027fbfd15 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/switch-non-final-default.expect.md @@ -31,9 +31,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(9); + const $ = useMemoCache(9); const c_0 = $[0] !== props; let x; let y; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/switch.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/switch.expect.md index 9571df01d9..b335f0a0bc 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/switch.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/switch.expect.md @@ -26,9 +26,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 c_0 = $[0] !== props; let x; let y; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/tagged-template-literal.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/tagged-template-literal.expect.md index 68fbe43026..5f49eaa136 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/tagged-template-literal.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/tagged-template-literal.expect.md @@ -24,9 +24,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 = graphql` diff --git a/compiler/forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md index ef71c3c99c..cbbeb555e9 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/temporary-at-start-of-value-block.expect.md @@ -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(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/timers.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/timers.expect.md index 009068d08a..70681ffb49 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/timers.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/timers.expect.md @@ -18,9 +18,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 start = performance.now(); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md index 9fb169b413..e55e032231 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-cast-expression.flow.expect.md @@ -16,10 +16,10 @@ function Component(props) { ## Code ```javascript -import * as React from "react"; // @flow +import { unstable_useMemoCache as useMemoCache } from "react"; // @flow type Foo = { bar: string }; function Component(props) { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); const c_0 = $[0] !== props.bar; let y; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-field-load.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-field-load.expect.md index 566ef9efae..4099f127f8 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-field-load.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-field-load.expect.md @@ -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(1); + const $ = useMemoCache(1); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = { t: 1 }; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-load-binary-op.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-load-binary-op.expect.md index 3142ea7e98..b470aa29cb 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-load-binary-op.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-load-binary-op.expect.md @@ -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(3); + const $ = useMemoCache(3); let t0; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { t0 = makeSomePrimitive(); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-store.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-store.expect.md index bd257d89f7..0f9602226f 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-store.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-test-field-store.expect.md @@ -15,9 +15,9 @@ function component() { ## Code ```javascript -import * as React from "react"; +import { unstable_useMemoCache as useMemoCache } from "react"; function component() { - const $ = React.unstable_useMemoCache(2); + const $ = useMemoCache(2); let x; if ($[0] === Symbol.for("react.memo_cache_sentinel")) { x = {}; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md index c81bca6db8..0006510875 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-test-polymorphic.expect.md @@ -22,9 +22,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 = makePrimitive(); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/type-test-return-type-inference.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/type-test-return-type-inference.expect.md index 7c2d57f7e2..1dc1bf1852 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/type-test-return-type-inference.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/type-test-return-type-inference.expect.md @@ -18,9 +18,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); const x = foo(); const y = foo(); if (x > y) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/unary-expr.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/unary-expr.expect.md index 117be18550..f8ba650eac 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/unary-expr.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/unary-expr.expect.md @@ -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(8); + const $ = useMemoCache(8); const t = { t: a }; const z = +t.t; const q = -t.t; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md index 964e15b23b..bde5f57cb2 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/unused-object-element-with-rest.expect.md @@ -13,9 +13,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.a; let rest; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/update-expression.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/update-expression.expect.md index fdb6a5a663..662c3ac107 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/update-expression.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/update-expression.expect.md @@ -14,9 +14,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(4); + const $ = useMemoCache(4); let x = props.x; x = x + 1; const y = x; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md index 3ac6573f65..feeca21b18 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/use-callback-simple.expect.md @@ -14,9 +14,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 [count, setCount] = useState(0); const c_0 = $[0] !== setCount; const c_1 = $[1] !== count; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md index 144236e161..5e8096268e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useEffect-arg-memoized.expect.md @@ -24,9 +24,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 dispatch = useDispatch(); useFreeze(dispatch); const c_0 = $[0] !== dispatch; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md index 78893c0898..5e84d258d5 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useEffect-nested-lambdas.expect.md @@ -30,9 +30,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 item = useMutable(props.itemId); const dispatch = useDispatch(); useFreeze(dispatch); diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md index 900fc73558..1644e7a6c1 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-if-else-multiple-return.expect.md @@ -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(4); + const $ = useMemoCache(4); let t17 = undefined; if (props.cond) { const c_0 = $[0] !== props.a; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md index 20668af6d0..9cd86a91d0 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-independently-memoizeable.expect.md @@ -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(10); + const $ = useMemoCache(10); const c_0 = $[0] !== props.a; let t0; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md index 7218ad8e52..06b74a672e 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-inlining-block-return.expect.md @@ -16,9 +16,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); let t14 = undefined; if (a) { const c_0 = $[0] !== b; diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md index a876642a14..d6fcc5e540 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-multiple-if-else.expect.md @@ -22,9 +22,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; let t26; if (c_0) { diff --git a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md index 9d9a53d477..d1804c16b4 100644 --- a/compiler/forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md +++ b/compiler/forget/src/__tests__/fixtures/compiler/useMemo-simple.expect.md @@ -12,9 +12,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) { diff --git a/compiler/forget/src/__tests__/fixtures/disableMemoizeJsxElements/Component.expect.md b/compiler/forget/src/__tests__/fixtures/disableMemoizeJsxElements/Component.expect.md index 0daf18aff7..dc1eb2d124 100644 --- a/compiler/forget/src/__tests__/fixtures/disableMemoizeJsxElements/Component.expect.md +++ b/compiler/forget/src/__tests__/fixtures/disableMemoizeJsxElements/Component.expect.md @@ -19,9 +19,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 [name, setName] = useState(null); const c_0 = $[0] !== setName; let t0;