useMergeRef.d.ts 737 B

1234567891011121314151617
  1. import * as React 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 mergeRefs} a version without buit-in memoization
  9. * @see https://github.com/theKashey/use-callback-ref#usemergerefs
  10. * @example
  11. * const Component = React.forwardRef((props, ref) => {
  12. * const ownRef = useRef();
  13. * const domRef = useMergeRefs([ref, ownRef]); // 👈 merge together
  14. * return <div ref={domRef}>...</div>
  15. * }
  16. */
  17. export declare function useMergeRefs<T>(refs: ReactRef<T>[], defaultValue?: T): React.MutableRefObject<T | null>;