Skip to content

Commit

Permalink
[ez] Update references to 'forget' in react-compiler-runtime (#31277)
Browse files Browse the repository at this point in the history
Updates the runtime to reference React Compiler instead of Forget.
  • Loading branch information
poteto authored Oct 16, 2024
1 parent a3d9ea0 commit 3ed64f8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions compiler/packages/react-compiler-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

'use no forget';
'use no memo';

import * as React from 'react';

Expand Down Expand Up @@ -67,7 +67,7 @@ const LazyGuardDispatcher: {[key: string]: (...args: Array<any>) => any} = {};
].forEach(name => {
LazyGuardDispatcher[name] = () => {
throw new Error(
`[React] Unexpected React hook call (${name}) from a React Forget compiled function. ` +
`[React] Unexpected React hook call (${name}) from a React compiled function. ` +
"Check that all hooks are called directly and named according to convention ('use[A-Z]') ",
);
};
Expand All @@ -79,7 +79,7 @@ let originalDispatcher: unknown = null;
LazyGuardDispatcher['useMemoCache'] = (count: number) => {
if (originalDispatcher == null) {
throw new Error(
'React Forget internal invariant violation: unexpected null dispatcher',
'React Compiler internal invariant violation: unexpected null dispatcher',
);
} else {
return (originalDispatcher as any).useMemoCache(count);
Expand All @@ -103,12 +103,12 @@ const guardFrames: Array<unknown> = [];
/**
* When `enableEmitHookGuards` is set, this does runtime validation
* of the no-conditional-hook-calls rule.
* As Forget needs to statically understand which calls to move out of
* conditional branches (i.e. Forget cannot memoize the results of hook
* As React Compiler needs to statically understand which calls to move out of
* conditional branches (i.e. React Compiler cannot memoize the results of hook
* calls), its understanding of "the rules of React" are more restrictive.
* This validation throws on unsound inputs at runtime.
*
* Components should only be invoked through React as Forget could memoize
* Components should only be invoked through React as React Compiler could memoize
* the call to AnotherComponent, introducing conditional hook calls in its
* compiled output.
* ```js
Expand Down Expand Up @@ -148,7 +148,7 @@ export function $dispatcherGuard(kind: GuardKind) {

if (curr === LazyGuardDispatcher) {
throw new Error(
`[React] Unexpected call to custom hook or component from a React Forget compiled function. ` +
`[React] Unexpected call to custom hook or component from a React compiled function. ` +
"Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') " +
'and (2) components are returned as JSX instead of being directly invoked.',
);
Expand All @@ -160,7 +160,7 @@ export function $dispatcherGuard(kind: GuardKind) {

if (lastFrame == null) {
throw new Error(
'React Forget internal error: unexpected null in guard stack',
'React Compiler internal error: unexpected null in guard stack',
);
}
if (guardFrames.length === 0) {
Expand All @@ -176,12 +176,12 @@ export function $dispatcherGuard(kind: GuardKind) {
const lastFrame = guardFrames.pop();
if (lastFrame == null) {
throw new Error(
'React Forget internal error: unexpected null in guard stack',
'React Compiler internal error: unexpected null in guard stack',
);
}
setCurrent(lastFrame);
} else {
throw new Error('Forget internal error: unreachable block' + kind);
throw new Error('React Compiler internal error: unreachable block' + kind);
}
}

Expand Down

0 comments on commit 3ed64f8

Please sign in to comment.