We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9f9cce commit 627560fCopy full SHA for 627560f
src/devtools/useLocalStorage.ts
@@ -13,15 +13,17 @@ const getItem = key => {
13
export default function useLocalStorage(key, defaultValue) {
14
const [value, setValue] = React.useState()
15
16
- useEffect(() => {
+ React.useEffect(() => {
17
const initialValue = getItem(key)
18
19
if (typeof initialValue === 'undefined' || initialValue === null) {
20
- setValue(typeof defaultValue === 'function' ? defaultValue() : defaultValue)
+ setValue(
21
+ typeof defaultValue === 'function' ? defaultValue() : defaultValue
22
+ )
23
} else {
24
setValue(initialValue)
25
}
- }, []);
26
+ }, [])
27
28
const setter = React.useCallback(
29
updater => {
0 commit comments