use-loc-storage
v1.0.4
Published
Easy to use React.js useLocalStorage hook for updating and subscribing to localStorage keys
Downloads
8
Maintainers
Readme
Easy to use React.js useLocalStorage hook for updating and subscribing to localStorage keys
Value for the given key will be in sync across different hook calls, components and tabs. Thats all.
import useLocalStorage from "use-loc-storage";
// Signature
type useLocalStorageFn = (key: string, initialValue?: string) => [string | null, (newValue: string) => void, () => void];
const [
value, // value of the given key
setValue, // set the value
clear // remove the key from localStorage
] = useLocalStorage('key','optional initial value');