forked from scaffold-eth/scaffold-eth-2
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch useLocalStorage setting the right initial value to avoid a hydr…
…ation error (scaffold-eth#356) Co-authored-by: sverps <[email protected]>
- Loading branch information
1 parent
c7af09a
commit 76c531e
Showing
3 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/dist/esm/useLocalStorage/useLocalStorage.js b/dist/esm/useLocalStorage/useLocalStorage.js | ||
index b0d584d4df29953551dfcf8febac002f89fa7acd..920ae5c52d28af73e3a892bdb935a7805a0f8224 100644 | ||
--- a/dist/esm/useLocalStorage/useLocalStorage.js | ||
+++ b/dist/esm/useLocalStorage/useLocalStorage.js | ||
@@ -14,7 +14,7 @@ function useLocalStorage(key, initialValue) { | ||
return initialValue; | ||
} | ||
}, [initialValue, key]); | ||
- const [storedValue, setStoredValue] = useState(readValue); | ||
+ const [storedValue, setStoredValue] = useState(initialValue); | ||
const setValue = useEventCallback(value => { | ||
if (typeof window === 'undefined') { | ||
console.warn(`Tried setting localStorage key “${key}” even though environment is not a client`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters