welcome-ui
Version:
Customizable design system with react, typescript, tailwindcss and ariakit.
21 lines (20 loc) • 932 B
TypeScript
import { default as React, Ref } from 'react';
/**
* Gets the ref of a child element if it exists.
* @param child - A React node which may have a ref.
* @returns The ref of the child element or null.
*/
export declare function getChildRef<T>(child: React.ReactNode): Ref<T>;
/**
* Merges multiple refs into a single ref callback.
*/
export declare function mergeRefs<T>(...refs: Array<Ref<T> | undefined>): (element: T) => void;
/**
* Sets the given ref to the provided element.
*/
export declare function setRef<T>(ref?: Ref<T>, element?: T): void;
/**
* Forks two refs into a single ref.
* @returns A tuple containing the current ref and the merged refs function. The current ref should be used to access the DOM element, while the merged refs function should be passed to the component.
*/
export declare function useForkRef<T>(refA?: Ref<T>, refB?: Ref<T>): [React.MutableRefObject<null | T>, (instance: T) => void];