From 6be51b024ce6c375ac14552bb4e3e7042641e652 Mon Sep 17 00:00:00 2001 From: Lauren Tan Date: Thu, 14 Nov 2024 10:14:02 -0500 Subject: [PATCH] [ez] Update useMemoCache return type Use `mixed` instead of `any` --- packages/react-debug-tools/src/ReactDebugHooks.js | 2 +- packages/react-reconciler/src/ReactFiberHooks.js | 2 +- packages/react-server/src/ReactFizzHooks.js | 2 +- packages/react/src/ReactHooks.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index 44d684003861b..b1e7a0272acea 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -560,7 +560,7 @@ function useId(): string { // useMemoCache is an implementation detail of Forget's memoization // it should not be called directly in user-generated code -function useMemoCache(size: number): Array { +function useMemoCache(size: number): Array { const fiber = currentFiber; // Don't throw, in case this is called from getPrimitiveStackCache if (fiber == null) { diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index 01f3b400adf70..174235fc76d65 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -1199,7 +1199,7 @@ function use(usable: Usable): T { throw new Error('An unsupported type was passed to use(): ' + String(usable)); } -function useMemoCache(size: number): Array { +function useMemoCache(size: number): Array { let memoCache = null; // Fast-path, load memo cache from wip fiber if already prepared let updateQueue: FunctionComponentUpdateQueue | null = diff --git a/packages/react-server/src/ReactFizzHooks.js b/packages/react-server/src/ReactFizzHooks.js index 5a33617d2186a..78e114e373e6b 100644 --- a/packages/react-server/src/ReactFizzHooks.js +++ b/packages/react-server/src/ReactFizzHooks.js @@ -792,7 +792,7 @@ function useCacheRefresh(): (?() => T, ?T) => void { return unsupportedRefresh; } -function useMemoCache(size: number): Array { +function useMemoCache(size: number): Array { const data = new Array(size); for (let i = 0; i < size; i++) { data[i] = REACT_MEMO_CACHE_SENTINEL; diff --git a/packages/react/src/ReactHooks.js b/packages/react/src/ReactHooks.js index 956a2a96b44a1..dba0d4be0f6c5 100644 --- a/packages/react/src/ReactHooks.js +++ b/packages/react/src/ReactHooks.js @@ -212,7 +212,7 @@ export function use(usable: Usable): T { return dispatcher.use(usable); } -export function useMemoCache(size: number): Array { +export function useMemoCache(size: number): Array { const dispatcher = resolveDispatcher(); // $FlowFixMe[not-a-function] This is unstable, thus optional return dispatcher.useMemoCache(size);