UNPKG

@kinvolk/headlamp-plugin

Version:

The needed infrastructure for building Headlamp plugins.

15 lines (14 loc) 686 B
/** * Custom hook to manage state synchronized with localStorage. * Value must by serializable to JSON. * * @template T - The type of the state value. * @param {string} key - The key under which the state is stored in localStorage. * @param {T} defaultValue - The default value to use if no value is found in localStorage. * @returns Returns a tuple containing the current state and a function to update the state. * * @example * const [value, setValue] = useLocalStorageState<string>('myKey', 'default'); * setValue((oldValue) => 'newValue'); */ export declare function useLocalStorageState<T>(key: string, defaultValue: T): readonly [T, (updater: (old: T) => T) => void];