Skip to content

Commit feb383d

Browse files
committed
Merge branch 'experimental' of https://github.com/uidotdev/usehooks into experimental
2 parents 7ca3533 + cb4ba62 commit feb383d

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

index.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,26 +1384,13 @@ export function useSessionStorage(key, initialValue) {
13841384
typeof value === "function" ? value(localState) : value;
13851385
window.sessionStorage.setItem(key, JSON.stringify(nextState));
13861386
setLocalState(nextState);
1387-
window.dispatchEvent(new Event("session-storage"));
13881387
} catch (e) {
13891388
console.warn(e);
13901389
}
13911390
},
13921391
[key, localState]
13931392
);
13941393

1395-
const onStorageChange = React.useEffectEvent(() => {
1396-
setLocalState(readValue());
1397-
});
1398-
1399-
React.useEffect(() => {
1400-
window.addEventListener("session-storage", onStorageChange);
1401-
1402-
return () => {
1403-
window.removeEventListener("session-storage", onStorageChange);
1404-
};
1405-
}, []);
1406-
14071394
return [localState, handleSetState];
14081395
}
14091396

0 commit comments

Comments
 (0)