UNPKG

@yamada-ui/use-local-storage

Version:

Yamada UI useLocalStorage custom hook

18 lines (16 loc) 910 B
type StorageType = "localStorage" | "sessionStorage"; interface StorageProps<T> { key: string; defaultValue?: T; deserialize?: (value: string | undefined) => T; getInitialValueInEffect?: boolean; serialize?: (value: T) => string; } declare const createStorage: <T>(type: StorageType, name: string) => ({ key, defaultValue, deserialize, getInitialValueInEffect, serialize, }: StorageProps<T>) => readonly [T | undefined, (valOrFunc: ((prevState: T) => T) | T) => void, () => void]; /** * `useLocalStorage` is a custom hook for storing, updating, and retrieving values in local storage. * * @see Docs https://yamada-ui.com/hooks/use-local-storage */ declare const useLocalStorage: <T = string>(props: StorageProps<T>) => readonly [T | undefined, (valOrFunc: T | ((prevState: T) => T)) => void, () => void]; export { type StorageProps, type StorageType, createStorage, useLocalStorage };