Fix usage of renamed React internals
ghstack-source-id: d646c84815c324bd490584d34488a73f5e39d589 Pull Request resolved: https://github.com/facebook/react-forget/pull/2845
Lauren Tan committed
Apr 11, 2024 at 11:10 UTC
c836a0158b8720fa368574068dfca925d28430b5
1 file changed
+9
-11
compiler/packages/react-forget-runtime/src/index.ts
+9
-11
@@ -9,14 +9,12 @@
9
10
import * as React from "react";
11
12
-const {
13
- // @ts-ignore
14
- __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: {
15
- ReactCurrentDispatcher,
16
- },
17
- useRef,
18
- useEffect,
19
-} = React;
12
+const { useRef, useEffect } = React;
13
+const ReactSecretInternals =
14
+ //@ts-ignore
15
+ React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ??
16
+ //@ts-ignore
17
+ React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
18
19
type MemoCache = Array<number | typeof $empty>;
20
@@ -95,8 +93,8 @@ enum GuardKind {
93
}
94
95
function setCurrent(newDispatcher: any) {
98
- ReactCurrentDispatcher.current = newDispatcher;
99
- return ReactCurrentDispatcher.current;
96
+ ReactSecretInternals.ReactCurrentDispatcher.current = newDispatcher;
97
+ return ReactSecretInternals.ReactCurrentDispatcher.current;
98
}
99
100
const guardFrames: Array<unknown> = [];
@@ -137,7 +135,7 @@ const guardFrames: Array<unknown> = [];
135
* ```
136
*/
137
export function $dispatcherGuard(kind: GuardKind) {
140
- const curr = ReactCurrentDispatcher.current;
138
+ const curr = ReactSecretInternals.ReactCurrentDispatcher.current;
139
if (kind === GuardKind.PushGuardContext) {
140
// Push before checking invariant or errors
141
guardFrames.push(curr);