react-localstorage-hooks
Version:
A collection of React hooks for reactively managing localStorage
15 lines (14 loc) • 648 B
TypeScript
interface useLocalStorageSelectorOptions<U> {
equalityFn?: (prev: U, next: U) => boolean;
}
/**
* Hook to query an data stored in the localStorage and reactively update when it changes.
* The hook only updates when the result of `selector` method changes.
*
* @param key Key of the localstorage store to be queried
* @param selector Selector function to select items from the store
* @param opts Options object
* @returns Data queried by the `selector` method
*/
declare function useLocalStorageSelector<T, U>(key: string, selector: (state: T) => U, opts?: useLocalStorageSelectorOptions<U>): U;
export default useLocalStorageSelector;