A React hook for merging multiple refs into one ref
npm install @react-hook/merged-refnpm i @react-hook/merged-ref
A React hook for merging multiple refs into one ref
``jsx harmony
import React from 'react'
import useMergedRef from '@react-hook/merged-ref'
const Component = React.forwardRef((props, ref) => {
const otherRef = React.useRef(null)
const multiRef = useMergedRef(ref, otherRef)
return
API
$3
`ts
function useMergedRef(...refs: React.Ref[]): React.RefCallback
`| Argument | Description |
| -------- | ------------------------------------------------------------------ |
| refs | React callback refs or refs created with
useRef(), createRef() |#### Returns
React.RefCallback`Returns a callback ref
MIT