Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/react-debug-tools/src/ReactDebugHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
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);
Expand Down Expand Up @@ -171,6 +175,16 @@ function useRef<T>(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<mixed> | void | null,
Expand Down Expand Up @@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
const Dispatcher: DispatcherType = {
getCacheForType,
readContext,
useCacheRefresh,
useCallback,
useContext,
useEffect,
Expand Down