diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index ce62b5ce8b9ef..5deb13e3cf837 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: 'Refresh', + stackError: new Error(), + value: hook !== null ? hook.memoizedState[0] : 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,