useMergeRefs is a custom hook used to merge several react refs into a single one.


import { useMergeRefs } from '@dwarvesf/react-hooks'

Return value#

The useMergeRefs hook returns a function that receives the element and assign the value to the given React refs.


function Example({ ref, ...props }) {
const internalRef = React.useRef()
const refs = useMergeRefs(internalRef, ref)
return (
<div {...props} ref={refs}>
A div with multiple refs.
Edit this page

Made with ❤️ by Dwarves Foundation