@illinois/react-use-local-storage
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -34,6 +34,6 @@ "use strict"; | ||
}; | ||
const setState = (value) => { | ||
const setState = react_1.useCallback((value) => { | ||
window.localStorage.setItem(key, JSON.stringify(value)); | ||
updateState(value); | ||
}; | ||
}, [key, updateState]); | ||
react_1.useEffect(() => { | ||
@@ -40,0 +40,0 @@ window.addEventListener('storage', localStorageChanged); |
{ | ||
"name": "@illinois/react-use-local-storage", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "React hook that persists and syncs state with local storage", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -8,3 +8,3 @@ # react-use-local-storage | ||
``` | ||
npm i @illinois/react-use-local-state | ||
npm i @illinois/react-use-local-storage | ||
``` | ||
@@ -18,3 +18,3 @@ | ||
const MyComponent = () => { | ||
const [value, setValue] = useLocalStorage('value-key', 0) | ||
const [count, setCount] = useLocalStorage('value-key', 0) | ||
return ( | ||
@@ -21,0 +21,0 @@ <> |
Sorry, the diff of this file is not supported yet
6671