UNPKG

hightable

Version:

A dynamic windowed scrolling table component for react

23 lines (22 loc) 966 B
import { Dispatch, SetStateAction } from 'react'; /** * Hook to use a state that is persisted in local storage. * * The initial value is loaded from local storage if the key is defined. * If the key is undefined, the local storage is not used, and the initial value is undefined. * * 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? * * Contrarily to useState, the initial value is always undefined. * * @param options * @param [string | undefined] options.key The key to use in local storage. If undefined, the value is not persisted. * * @returns [T | undefined, Dispatch<SetStateAction<T | undefined>>] The value and the setter. */ export declare function useLocalStorageState<T>({ key }?: { key?: string; }): [T | undefined, Dispatch<SetStateAction<T | undefined>>];