UNPKG

react-localstorage-hooks

Version:

A collection of React hooks for reactively managing localStorage

16 lines (15 loc) 656 B
interface useLocalStorageReducerOptions<T> { initialState?: T; sync?: boolean; } export declare type LocalStorageReducer<T> = (state: T, action: any) => T; /** * An alternative hook to `useLocalStorageState` for managing complex state. * * @param key key for localStorage * @param reducer reducer method that returns new state * @param opts Options object * @returns a pair of current state and dispatch method to dispatch actions */ declare function useLocalStorageReducer<T>(key: string, reducer: LocalStorageReducer<T>, opts?: useLocalStorageReducerOptions<T>): readonly [T, (action: any) => void]; export default useLocalStorageReducer;