Skip to content

Commit 1dbaa2e

Browse files
committed
Refactor useLocalStorage
1 parent e5eec7b commit 1dbaa2e

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,6 @@ export function useLocalStorage(key, initialValue) {
814814
typeof value === "function" ? value(localState) : value;
815815
window.localStorage.setItem(key, JSON.stringify(nextState));
816816
setLocalState(nextState);
817-
window.dispatchEvent(new Event("local-storage"));
818817
} catch (e) {
819818
console.warn(e);
820819
}
@@ -828,11 +827,9 @@ export function useLocalStorage(key, initialValue) {
828827

829828
React.useEffect(() => {
830829
window.addEventListener("storage", onStorageChange);
831-
window.addEventListener("local-storage", onStorageChange);
832830

833831
return () => {
834832
window.removeEventListener("storage", onStorageChange);
835-
window.removeEventListener("local-storage", onStorageChange);
836833
};
837834
}, []);
838835

0 commit comments

Comments
 (0)