Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ez] Update references to 'forget' in react-compiler-runtime #31277

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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