UNPKG

use-smartvalue

Version:

A custom React hook to manage values with either useState or useRef.

15 lines (14 loc) 403 B
type UseValueOptions<T> = { initialValue: T; useRef?: boolean; }; type Updater<T> = (prevValue: T) => T; export type SmartValue<T> = { get: () => T; set: (value: T | Updater<T>) => void; getInitial: () => T; reset: () => void; getPrevious: () => T | undefined; }; export declare const useSmartValue: <T>(options?: UseValueOptions<T> | undefined) => SmartValue<T>; export {};