Skip to content
Discussion options

You must be logged in to vote

I updated my example to use createJSONStorage but that shouldn't do much since that is the default storage. What did clue me in to what is happening was adding

  useEffect(() => {
    const listener = (e) => {
      console.log(e);
    };
    window.addEventListener("storage", listener);

    return () => {
      window.removeEventListener("storage", listener);
    };
  }, []);

And it showed me that the events were only raised in the other browser windows/tabs not in the one I clicked the checkboxes in, this is true for both atoms both the ones using the same store and the ones that doesn't.

A quick look at MDN shows me that what I expected to happen was never going to be:

The StorageEv…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Zache
Comment options

Answer selected by Zache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
2 participants