mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 00:20:04 +01:00
Add useRefresh hook to react-debug-tools (#20460)
This commit is contained in:
parent
beb38aba3e
commit
27659559eb
|
|
@ -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);
|
||||
|
|
@ -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,
|
||||
|
|
@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
|
|||
const Dispatcher: DispatcherType = {
|
||||
getCacheForType,
|
||||
readContext,
|
||||
useCacheRefresh,
|
||||
useCallback,
|
||||
useContext,
|
||||
useEffect,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user