tg-use-local-storage-state
Version:
React hook that persists data in localStorage
23 lines (22 loc) • 692 B
TypeScript
import { Dispatch, SetStateAction } from 'react';
export declare type LocalStorageState<T> = [
T,
Dispatch<SetStateAction<T>>,
{
isPersistent: boolean;
removeItem: () => void;
}
];
export default function useLocalStorageState(key: string, options?: {
ssr: boolean;
isSimpleString?: boolean;
}): LocalStorageState<unknown>;
export default function useLocalStorageState<T>(key: string, options?: {
ssr: boolean;
isSimpleString?: boolean;
}): LocalStorageState<T | undefined>;
export default function useLocalStorageState<T>(key: string, options?: {
defaultValue?: T;
ssr?: boolean;
isSimpleString?: boolean;
}): LocalStorageState<T>;