React Hook that merges two or more refs into a single one.
npm install use-merge-refs
Checkout the demo page to see useMergeRefs in action ⛹️
import useMergeRefs from 'use-merge-refs';
function Example() {
const catRef = React.useRef();
const dogRef = React.useRef();
const refs = useMergeRefs(catRef, dogRef);
return <div ref={refs} />;
}
MIT License