import type { LegacyRef, MutableRefObject, RefCallback } from 'react'; import type { Nullable } from '../../types'; export const mergeRefs = ( refs: (MutableRefObject | LegacyRef | undefined | null)[] ): RefCallback => (value) => { refs.forEach((ref) => { if (typeof ref === 'function') { ref(value); } else if (ref !== null) { (ref as MutableRefObject>).current = value; } }); };