werkbank
    Preparing search index...

    Function useCombinedRefs

    • Combines multiple refs into a single callback ref.

      Type Parameters

      • T

        The type of the element.

      Parameters

      • ...refs: (Ref<T> | undefined)[]

        The refs to combine.

      Returns RefCallback<T>

      A callback ref that updates all provided refs.

      Useful when you need to forward a ref to a child component but also need to access the DOM node locally. It handles both callback refs and object refs.

      const ref1 = useRef(null);
      const ref2 = useRef(null);
      const combinedRef = useCombinedRefs(ref1, ref2);
      return <div ref={combinedRef} />;