@supunlakmal/hooks
Version:
A collection of reusable React hooks
23 lines (22 loc) • 759 B
TypeScript
type UseCounterReturn = {
count: number;
increment: () => void;
decrement: () => void;
set: (newCount: number) => void;
reset: () => void;
};
/**
* A hook that provides a counter state that persists in local storage,
* supporting min, max, and step options.
*
* @param key The key to use in local storage.
* @param initialValue The initial value for the counter if not found in storage, defaults to 0.
* @param options Options for the counter (min, max, step).
* @returns An object containing the current count and counter manipulation functions.
*/
export declare function usePersistentCounter(key: string, initialValue?: number, options?: {
min?: number;
max?: number;
step?: number;
}): UseCounterReturn;
export {};