@storm-stack/hooks
Version:
A collection of React hooks used by Storm Software in various client libraries and applications.
26 lines (25 loc) • 871 B
TypeScript
import { Ref } from "react";
/**
* Set a given ref to a given value
* This utility takes care of different types of refs: callback refs and RefObject(s)
*
* @param ref - The ref to set
* @param value - The value to set the ref to
*/
export declare function setRef<T>(ref: Ref<T> | undefined, value: T): void;
/**
* A utility to compose multiple refs together
* Accepts callback refs and RefObject(s)
*
* @param refs - The refs to compose
* @returns A function that sets all refs to a given value
*/
export declare function composeRefs<T>(...refs: Ref<T>[]): (node: T) => void;
/**
* A custom hook that composes multiple refs
* Accepts callback refs and RefObject(s)
*
* @param refs - The refs to compose
* @returns A function that sets all refs to a given value
*/
export declare function useComposedRefs<T>(...refs: Ref<T>[]): (node: unknown) => void;