UNPKG

704 BTypeScriptView Raw
1import { MutableRefObject } from 'react';
2/**
3 * useLazyRef provides a lazy initial value, similar to lazy
4 * initial state the initialValue is the value used during
5 * initialization and disregarded after that. Use this hook
6 * for expensive initialization.
7 * @param initialValue - A function that will return the initial
8 * value and be disregarded after that
9 * @returns MutableRefObject<T> - Returns a ref object with the
10 * results from invoking initial value
11 * @example
12 * function ComponentExample() {
13 * const title = useLazyRef(() => someExpensiveComputation());
14 * return <h1>{title.current}</h1>;
15 * }
16 */
17export declare function useLazyRef<T>(initialValue: () => T): MutableRefObject<T>;