UNPKG

@supunlakmal/hooks

Version:

A collection of reusable React hooks

17 lines (16 loc) 726 B
type Initializer<T> = () => T; /** * Initializes and returns a constant value that persists across component renders. * * This is useful for creating object instances, arrays, or other values that should only be * created once per component instance and remain stable. * * It uses a `useRef` internally to store the value. * * @template T The type of the constant value. * @param {Initializer<T> | T} initializer A function that returns the initial value, or the initial value itself. * If a function is provided, it's guaranteed to be called only once. * @returns {T} The constant value. */ export declare function useConst<T>(initializer: Initializer<T> | T): T; export {};