[ez] Update references to 'forget' in react-compiler-runtime (#31277)
Updates the runtime to reference React Compiler instead of Forget.
lauren committed
Oct 16, 2024 at 18:44 UTC
3ed64f8232d0709f93f096c6fb9f7a16865b0ff5
1 file changed
+10
-10
compiler/packages/react-compiler-runtime/src/index.ts
+10
-10
@@ -5,7 +5,7 @@
5
* LICENSE file in the root directory of this source tree.
6
*/
7
8
-'use no forget';
8
+'use no memo';
9
10
import * as React from 'react';
11
@@ -67,7 +67,7 @@ const LazyGuardDispatcher: {[key: string]: (...args: Array<any>) => any} = {};
67
].forEach(name => {
68
LazyGuardDispatcher[name] = () => {
69
throw new Error(
70
- `[React] Unexpected React hook call (${name}) from a React Forget compiled function. ` +
70
+ `[React] Unexpected React hook call (${name}) from a React compiled function. ` +
71
"Check that all hooks are called directly and named according to convention ('use[A-Z]') ",
72
);
73
};
@@ -79,7 +79,7 @@ let originalDispatcher: unknown = null;
79
LazyGuardDispatcher['useMemoCache'] = (count: number) => {
80
if (originalDispatcher == null) {
81
throw new Error(
82
- 'React Forget internal invariant violation: unexpected null dispatcher',
82
+ 'React Compiler internal invariant violation: unexpected null dispatcher',
83
);
84
} else {
85
return (originalDispatcher as any).useMemoCache(count);
@@ -103,12 +103,12 @@ const guardFrames: Array<unknown> = [];
103
/**
104
* When `enableEmitHookGuards` is set, this does runtime validation
105
* of the no-conditional-hook-calls rule.
106
- * As Forget needs to statically understand which calls to move out of
107
- * conditional branches (i.e. Forget cannot memoize the results of hook
106
+ * As React Compiler needs to statically understand which calls to move out of
107
+ * conditional branches (i.e. React Compiler cannot memoize the results of hook
108
* calls), its understanding of "the rules of React" are more restrictive.
109
* This validation throws on unsound inputs at runtime.
110
*
111
- * Components should only be invoked through React as Forget could memoize
111
+ * Components should only be invoked through React as React Compiler could memoize
112
* the call to AnotherComponent, introducing conditional hook calls in its
113
* compiled output.
114
* ```js
@@ -148,7 +148,7 @@ export function $dispatcherGuard(kind: GuardKind) {
148
149
if (curr === LazyGuardDispatcher) {
150
throw new Error(
151
- `[React] Unexpected call to custom hook or component from a React Forget compiled function. ` +
151
+ `[React] Unexpected call to custom hook or component from a React compiled function. ` +
152
"Check that (1) all hooks are called directly and named according to convention ('use[A-Z]') " +
153
'and (2) components are returned as JSX instead of being directly invoked.',
154
);
@@ -160,7 +160,7 @@ export function $dispatcherGuard(kind: GuardKind) {
160
161
if (lastFrame == null) {
162
throw new Error(
163
- 'React Forget internal error: unexpected null in guard stack',
163
+ 'React Compiler internal error: unexpected null in guard stack',
164
);
165
}
166
if (guardFrames.length === 0) {
@@ -176,12 +176,12 @@ export function $dispatcherGuard(kind: GuardKind) {
176
const lastFrame = guardFrames.pop();
177
if (lastFrame == null) {
178
throw new Error(
179
- 'React Forget internal error: unexpected null in guard stack',
179
+ 'React Compiler internal error: unexpected null in guard stack',
180
);
181
}
182
setCurrent(lastFrame);
183
} else {
184
- throw new Error('Forget internal error: unreachable block' + kind);
184
+ throw new Error('React Compiler internal error: unreachable block' + kind);
185
}
186
}
187