mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +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.useState(null);
|
||||||
Dispatcher.useReducer((s, a) => s, null);
|
Dispatcher.useReducer((s, a) => s, null);
|
||||||
Dispatcher.useRef(null);
|
Dispatcher.useRef(null);
|
||||||
|
if (typeof Dispatcher.useCacheRefresh === 'function') {
|
||||||
|
// This type check is for Flow only.
|
||||||
|
Dispatcher.useCacheRefresh();
|
||||||
|
}
|
||||||
Dispatcher.useLayoutEffect(() => {});
|
Dispatcher.useLayoutEffect(() => {});
|
||||||
Dispatcher.useEffect(() => {});
|
Dispatcher.useEffect(() => {});
|
||||||
Dispatcher.useImperativeHandle(undefined, () => null);
|
Dispatcher.useImperativeHandle(undefined, () => null);
|
||||||
|
|
@ -171,6 +175,16 @@ function useRef<T>(initialValue: T): {|current: T|} {
|
||||||
return ref;
|
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(
|
function useLayoutEffect(
|
||||||
create: () => (() => void) | void,
|
create: () => (() => void) | void,
|
||||||
inputs: Array<mixed> | void | null,
|
inputs: Array<mixed> | void | null,
|
||||||
|
|
@ -305,6 +319,7 @@ function useOpaqueIdentifier(): OpaqueIDType | void {
|
||||||
const Dispatcher: DispatcherType = {
|
const Dispatcher: DispatcherType = {
|
||||||
getCacheForType,
|
getCacheForType,
|
||||||
readContext,
|
readContext,
|
||||||
|
useCacheRefresh,
|
||||||
useCallback,
|
useCallback,
|
||||||
useContext,
|
useContext,
|
||||||
useEffect,
|
useEffect,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user