useMergedRefs
Combine a forwarded ref with your own refs.
One stable callback ref that forwards the node to every ref passed, object or callback, including React 19 ref cleanups.
Usage
Examples
Forward a ref and keep your own
API
1 option
1 return value
Accessibility
Lets a component keep its own ref for focus management while still forwarding the host ref.
Notes
mergeRefs(...refs)is exported for use outside components.
Related
useBooleanGeneric boolean state with stable toggle, enable and disable actions.useControllableStateState that works controlled or uncontrolled, like native inputs.useCountdownA pausable countdown or count-up that stops at its target.useCounterA number with increment, decrement, set and reset actions.useDebounceCallbackA debounced function with cancel and flush.useDebounceValueA value that updates only after it stops changing.