next
Version:
The React Framework
15 lines (14 loc) • 499 B
TypeScript
import type * as React from 'react';
/**
* A function that merges React refs into one.
* Supports both functions and ref objects created using createRef() and useRef().
*
* Usage:
* ```tsx
* <div ref={mergeRefs(ref1, ref2, ref3)} />
* ```
*
* @param {(React.Ref<T> | undefined)[]} inputRefs Array of refs
* @returns {React.Ref<T> | React.RefCallback<T>} Merged refs
*/
export default function mergeRefs<T>(...inputRefs: (React.Ref<T> | undefined)[]): React.Ref<T> | React.RefCallback<T>;