Skip to content

Commit 627560f

Browse files
committed
fix: useEffect is now defined
Fixes TanStack#1787
1 parent f9f9cce commit 627560f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/devtools/useLocalStorage.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@ const getItem = key => {
1313
export default function useLocalStorage(key, defaultValue) {
1414
const [value, setValue] = React.useState()
1515

16-
useEffect(() => {
16+
React.useEffect(() => {
1717
const initialValue = getItem(key)
1818

1919
if (typeof initialValue === 'undefined' || initialValue === null) {
20-
setValue(typeof defaultValue === 'function' ? defaultValue() : defaultValue)
20+
setValue(
21+
typeof defaultValue === 'function' ? defaultValue() : defaultValue
22+
)
2123
} else {
2224
setValue(initialValue)
2325
}
24-
}, []);
26+
}, [])
2527

2628
const setter = React.useCallback(
2729
updater => {

0 commit comments

Comments
 (0)