import type { Dispatch, SetStateAction } from 'react'; type Parse = (value: string) => T; type Stringify = (value: T) => string; interface Options { key?: string; parse?: Parse; stringify?: Stringify; } /** * Hook to use a state that is persisted in local storage. * * If the key is not defined, it's a normal useState hook. The only difference is that the initial value is always undefined. * * If the key is defined, the initial value is loaded from local storage, and the value is persisted in local storage after each change. * * If the key changes, the value is updated from local storage. If the new key is undefined, the value does not change. * Note that the values stored with a previous key are maintained. * TODO(SL): add a way to delete them? * * @param options * @param [string | undefined] options.key The key to use in local storage. If undefined, the value is not persisted. * @param [function] options.parse A function to parse the value from local storage. If not provided, JSON.parse is used. * @param [function] options.stringify A function to stringify the value to local storage. If not provided, JSON.stringify is used. * * @returns [T | undefined, Dispatch>] The value and the setter. */ export declare function useLocalStorageState({ key, parse, stringify }?: Options): [T | undefined, Dispatch>]; export {};