/** * Combine refs to allow assignment to all passed refs */ export default function mergeRefs( refs: Array | React.LegacyRef | undefined> ): React.RefCallback { return value => { refs.forEach(ref => { if (typeof ref === 'function') { ref(value); } else if (ref !== null && ref !== undefined) { (ref as React.MutableRefObject).current = value; } }); }; }