diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index ce62b5ce8b9ef..7ad315db20210 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.useRefresh === 'function') { + // This type check is for Flow only. + Dispatcher.useRefresh(); + } Dispatcher.useLayoutEffect(() => {}); Dispatcher.useEffect(() => {}); Dispatcher.useImperativeHandle(undefined, () => null); @@ -171,6 +175,16 @@ function useRef(initialValue: T): {|current: T|} { return ref; } +function useRefresh(): () => 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, @@ -314,6 +328,7 @@ const Dispatcher: DispatcherType = { useMemo, useReducer, useRef, + useRefresh, useState, useTransition, useMutableSource,