mergeRef.d.ts 645 B

12345678910111213141516
  1. import { MutableRefObject } from 'react';
  2. import { ReactRef } from './types';
  3. /**
  4. * Merges two or more refs together providing a single interface to set their value
  5. * @param {RefObject|Ref} refs
  6. * @returns {MutableRefObject} - a new ref, which translates all changes to {refs}
  7. *
  8. * @see {@link useMergeRefs} to be used in ReactComponents
  9. * @example
  10. * const Component = React.forwardRef((props, ref) => {
  11. * const ownRef = useRef();
  12. * const domRef = mergeRefs([ref, ownRef]); // 👈 merge together
  13. * return <div ref={domRef}>...</div>
  14. * }
  15. */
  16. export declare function mergeRefs<T>(refs: ReactRef<T>[]): MutableRefObject<T | null>;