useMergedRefs

    API

    import useMergedRefs from '@restart/hooks/useMergedRefs'
    • useMergedRefs<T>(refA?: Ref<T> | null, refB?: Ref<T> | null) => function

      Create and returns a single callback ref composed from two other Refs.

      const Button = React.forwardRef((props, ref) => {
      const [element, attachRef] = useCallbackRef<HTMLButtonElement>();
      const mergedRef = useMergedRefs(ref, attachRef);
      return <button ref={mergedRef} {...props}/>
      })

      Parameters

      • refA?Ref<T> | null

        A Callback or mutable Ref

      • refB?Ref<T> | null

        A Callback or mutable Ref

      Return Value function