1.27 kBTypeScriptView Raw
1import * as React from "react";
2export declare function isRefObject<T>(value: React.Ref<T> | undefined): value is React.RefObject<T>;
3export declare function isRefCallback<T>(value: React.Ref<T> | undefined): value is React.RefCallback<T>;
5 * Assign the given ref to a target, either a React ref object or a callback which takes the ref as its first argument.
6 */
7export declare function setRef<T>(refTarget: React.Ref<T> | undefined, ref: T | null): void;
9 * Utility for merging refs into one singular callback ref.
10 * If using in a functional component, would recomend using `useMemo` to preserve function identity.
11 */
12export declare function mergeRefs<T>(...refs: Array<React.Ref<T>>): React.RefCallback<T>;
13export declare function getRef<T>(ref: T | React.RefObject<T> | null): T | null;
15 * Creates a ref handler which assigns the ref returned by React for a mounted component to a field on the target object.
16 * The target object is usually a component class.
17 *
18 * If provided, it will also update the given `refProp` with the value of the ref.
19 */
20export declare function refHandler<T extends HTMLElement, K extends string>(refTargetParent: {
21 [k in K]: T | null;
22}, refTargetKey: K, refProp?: React.Ref<T> | undefined): React.RefCallback<T>;