Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useMergedRefs.d.ts 821B

123456789101112131415161718192021
  1. /// <reference types="react" />
  2. declare type CallbackRef<T> = (ref: T | null) => void;
  3. declare type Ref<T> = React.MutableRefObject<T> | CallbackRef<T>;
  4. export declare function mergeRefs<T>(refA?: Ref<T> | null, refB?: Ref<T> | null): (value: T | null) => void;
  5. /**
  6. * Create and returns a single callback ref composed from two other Refs.
  7. *
  8. * ```tsx
  9. * const Button = React.forwardRef((props, ref) => {
  10. * const [element, attachRef] = useCallbackRef<HTMLButtonElement>();
  11. * const mergedRef = useMergedRefs(ref, attachRef);
  12. *
  13. * return <button ref={mergedRef} {...props}/>
  14. * })
  15. * ```
  16. *
  17. * @param refA A Callback or mutable Ref
  18. * @param refB A Callback or mutable Ref
  19. */
  20. declare function useMergedRefs<T>(refA?: Ref<T> | null, refB?: Ref<T> | null): (value: T | null) => void;
  21. export default useMergedRefs;