From c836a0158b8720fa368574068dfca925d28430b5 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 11 Apr 2024 11:10:42 -0400 Subject: [PATCH] Fix usage of renamed React internals ghstack-source-id: d646c84815c324bd490584d34488a73f5e39d589 Pull Request resolved: https://github.com/facebook/react-forget/pull/2845 --- .../react-forget-runtime/src/index.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/compiler/packages/react-forget-runtime/src/index.ts b/compiler/packages/react-forget-runtime/src/index.ts index 7132e56ef7..8c9658e6fe 100644 --- a/compiler/packages/react-forget-runtime/src/index.ts +++ b/compiler/packages/react-forget-runtime/src/index.ts @@ -9,14 +9,12 @@ import * as React from "react"; -const { - // @ts-ignore - __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: { - ReactCurrentDispatcher, - }, - useRef, - useEffect, -} = React; +const { useRef, useEffect } = React; +const ReactSecretInternals = + //@ts-ignore + React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE ?? + //@ts-ignore + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; type MemoCache = Array; @@ -95,8 +93,8 @@ enum GuardKind { } function setCurrent(newDispatcher: any) { - ReactCurrentDispatcher.current = newDispatcher; - return ReactCurrentDispatcher.current; + ReactSecretInternals.ReactCurrentDispatcher.current = newDispatcher; + return ReactSecretInternals.ReactCurrentDispatcher.current; } const guardFrames: Array = []; @@ -137,7 +135,7 @@ const guardFrames: Array = []; * ``` */ export function $dispatcherGuard(kind: GuardKind) { - const curr = ReactCurrentDispatcher.current; + const curr = ReactSecretInternals.ReactCurrentDispatcher.current; if (kind === GuardKind.PushGuardContext) { // Push before checking invariant or errors guardFrames.push(curr);