useMergedRefs
API
import useMergedRefs from '@restart/hooks/useMergedRefs'
useMergedRefs
<T>(refA?: Ref<T> | null, refB?: Ref<T> | null) => functionCreate 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> | nullA Callback or mutable Ref
refB?
Ref<T> | nullA Callback or mutable Ref
Return Value function