@thibault.sh/hooks
Version:
A comprehensive collection of React hooks for browser storage, UI interactions, and more
12 lines (10 loc) • 488 B
text/typescript
/**
* Hook for managing state persisted in localStorage
* @param key - The localStorage key
* @param initialValue - The initial value to use if no value exists in storage
* @returns A tuple containing the current value and a setter function
* @example
* const [value, setValue] = useLocalStorageState('my-key', 'initial value');
*/
declare function useLocalStorageState<T>(key: string, initialValue: T): [T, (value: T | ((val: T) => T)) => void];
export { useLocalStorageState };