Skip to Content

Merge Refs

Exports Size
loading...
Gzip Size
loading...
Brotli Size
Source Code
View on GitHub
Docs
Edit this page

mergeRefs allows you to merge multiple refs into a single ref callback, enabling you to attach multiple refs to a single DOM element or component instance. It works seamlessly across different ref types and React versions.

React 19+

React 19 introduced cleanup functions that can be returned from ref callbacks.

Our version of mergeRefs supports both React 19 new ref callback behavior and the traditional (React 18 and earlier) ref callback behavior, ensuring compatibility across React versions.