diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js index b53fab87d46d8..cd25588220fe5 100644 --- a/packages/react-debug-tools/src/ReactDebugHooks.js +++ b/packages/react-debug-tools/src/ReactDebugHooks.js @@ -142,7 +142,7 @@ function useRef(initialValue: T): {current: T} { } function useLayoutEffect( - create: () => mixed, + create: () => (() => void) | void, inputs: Array | void | null, ): void { nextHook(); @@ -154,7 +154,7 @@ function useLayoutEffect( } function useEffect( - create: () => mixed, + create: () => (() => void) | void, inputs: Array | void | null, ): void { nextHook(); diff --git a/packages/react-dom/src/server/ReactPartialRendererHooks.js b/packages/react-dom/src/server/ReactPartialRendererHooks.js index 558c34064b2c5..134f9e1a80b45 100644 --- a/packages/react-dom/src/server/ReactPartialRendererHooks.js +++ b/packages/react-dom/src/server/ReactPartialRendererHooks.js @@ -329,7 +329,7 @@ function useRef(initialValue: T): {current: T} { } export function useLayoutEffect( - create: () => mixed, + create: () => (() => void) | void, inputs: Array | void | null, ) { if (__DEV__) { diff --git a/packages/react-reconciler/src/ReactFiberHooks.js b/packages/react-reconciler/src/ReactFiberHooks.js index a75f5cb212921..646cbc4464457 100644 --- a/packages/react-reconciler/src/ReactFiberHooks.js +++ b/packages/react-reconciler/src/ReactFiberHooks.js @@ -66,8 +66,8 @@ export type Hook = { type Effect = { tag: HookEffectTag, - create: () => mixed, - destroy: (() => mixed) | null, + create: () => (() => void) | void, + destroy: (() => void) | null, deps: Array | null, next: Effect, }; @@ -608,7 +608,7 @@ export function useRef(initialValue: T): {current: T} { } export function useLayoutEffect( - create: () => mixed, + create: () => (() => void) | void, deps: Array | void | null, ): void { if (__DEV__) { @@ -618,7 +618,7 @@ export function useLayoutEffect( } export function useEffect( - create: () => mixed, + create: () => (() => void) | void, deps: Array | void | null, ): void { if (__DEV__) { @@ -679,7 +679,9 @@ export function useImperativeHandle( const refCallback = ref; const inst = create(); refCallback(inst); - return () => refCallback(null); + return () => { + refCallback(null); + }; } else if (ref !== null && ref !== undefined) { const refObject = ref; const inst = create(); diff --git a/packages/react/src/ReactHooks.js b/packages/react/src/ReactHooks.js index 37f85cd5c3537..dc35ed8c5e780 100644 --- a/packages/react/src/ReactHooks.js +++ b/packages/react/src/ReactHooks.js @@ -71,7 +71,7 @@ export function useRef(initialValue: T): {current: T} { } export function useEffect( - create: () => mixed, + create: () => (() => void) | void, inputs: Array | void | null, ) { const dispatcher = resolveDispatcher(); @@ -79,7 +79,7 @@ export function useEffect( } export function useLayoutEffect( - create: () => mixed, + create: () => (() => void) | void, inputs: Array | void | null, ) { const dispatcher = resolveDispatcher();