diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index ce62b5ce8b9e..eb7a8f6d4ef1 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -73,6 +73,10 @@ function getPrimitiveStackCache(): Map> { Dispatcher.useState(null); Dispatcher.useReducer((s, a) => s, null); Dispatcher.useRef(null); + if (typeof Dispatcher.useCacheRefresh === 'function') { + // This type check is for Flow only. + Dispatcher.useCacheRefresh(); + } Dispatcher.useLayoutEffect(() => {}); Dispatcher.useEffect(() => {}); Dispatcher.useImperativeHandle(undefined, () => null); @@ -171,6 +175,16 @@ function useRef(initialValue: T): {|current: T|} { return ref; } +function useCacheRefresh(): () => void { + const hook = nextHook(); + hookLog.push({ + primitive: 'CacheRefresh', + stackError: new Error(), + value: hook !== null ? hook.memoizedState : function refresh() {}, + }); + return () => {}; +} + function useLayoutEffect( create: () => (() => void) | void, inputs: Array | void | null, @@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void { const Dispatcher: DispatcherType = { getCacheForType, readContext, + useCacheRefresh, useCallback, useContext, useEffect,