UNPKG

@thibault.sh/hooks

Version:

A comprehensive collection of React hooks for browser storage, UI interactions, and more

12 lines (10 loc) 498 B
/** * Hook for managing state persisted in sessionStorage * @param key - The sessionStorage 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] = useSessionStorageState('my-key', 'initial value'); */ declare function useSessionStorageState<T>(key: string, initialValue: T): [T, (value: T | ((val: T) => T)) => void]; export { useSessionStorageState };