From 82d13e5d3fc21982a36d9d56bc1a6dcd4aabb624 Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Fri, 21 May 2021 08:13:40 -0700 Subject: [PATCH] Node can be null --- packages/compose/README.md | 2 +- packages/compose/src/hooks/use-ref-effect/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/compose/README.md b/packages/compose/README.md index 2ec0419ea2501b..ce98b5e6314612 100644 --- a/packages/compose/README.md +++ b/packages/compose/README.md @@ -399,7 +399,7 @@ _Parameters_ _Returns_ -- `import('react').RefCallback`: Ref callback. +- `import('react').RefCallback`: Ref callback. # **useResizeObserver** diff --git a/packages/compose/src/hooks/use-ref-effect/index.js b/packages/compose/src/hooks/use-ref-effect/index.js index 6118b1fb14518d..3ad97d9990ebbe 100644 --- a/packages/compose/src/hooks/use-ref-effect/index.js +++ b/packages/compose/src/hooks/use-ref-effect/index.js @@ -20,12 +20,12 @@ import { useCallback, useRef } from '@wordpress/element'; * @param {(node: Node) => (() => void) | undefined} callback Callback with ref as argument. * @param {import('react').DependencyList} dependencies Dependencies of the callback. * - * @return {import('react').RefCallback} Ref callback. + * @return {import('react').RefCallback} Ref callback. */ export default function useRefEffect( callback, dependencies ) { /** @type {import('react').MutableRefObject<(() => void) | undefined>} */ const cleanup = useRef(); - return useCallback( ( /** @type {Node} */ node ) => { + return useCallback( ( /** @type {Node | null} */ node ) => { if ( node ) { cleanup.current = callback( node ); } else if ( cleanup.current ) {