GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add useRefresh hook to react-debug-tools (#20460) · react/react@2765955

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-debug-tools/src
    • ReactDebugHooks.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-debug-tools/src/ReactDebugHooks.js‎

Copy file name to clipboardExpand all lines: packages/react-debug-tools/src/ReactDebugHooks.js
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ function getPrimitiveStackCache(): Map<string, Array<any>> {
7373
Dispatcher.useState(null);
7474
Dispatcher.useReducer((s, a) => s, null);
7575
Dispatcher.useRef(null);
76+
if (typeof Dispatcher.useCacheRefresh === 'function') {
77+
// This type check is for Flow only.
78+
Dispatcher.useCacheRefresh();
79+
}
7680
Dispatcher.useLayoutEffect(() => {});
7781
Dispatcher.useEffect(() => {});
7882
Dispatcher.useImperativeHandle(undefined, () => null);
@@ -171,6 +175,16 @@ function useRef<T>(initialValue: T): {|current: T|} {
171175
return ref;
172176
}
173177

178+
function useCacheRefresh(): () => void {
179+
const hook = nextHook();
180+
hookLog.push({
181+
primitive: 'CacheRefresh',
182+
stackError: new Error(),
183+
value: hook !== null ? hook.memoizedState : function refresh() {},
184+
});
185+
return () => {};
186+
}
187+
174188
function useLayoutEffect(
175189
create: () => (() => void) | void,
176190
inputs: Array<mixed> | void | null,
@@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
305319
const Dispatcher: DispatcherType = {
306320
getCacheForType,
307321
readContext,
322+
useCacheRefresh,
308323
useCallback,
309324
useContext,
310325
useEffect,

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.