Skip to content

Location state is lost when updating the hash #11245

Closed Answered by foxaltus
foxaltus asked this question in Q&A
Discussion options

You must be logged in to vote

OK I think I found the solution, thanks to jotaijs/jotai-location#4:

- const countAtom = atomWithHash<number>("count", 0);
+ const countAtom = atomWithHash<number>("count", 0, { setHash: "replaceState" }); 

This way, the state is not reset when the hash changes. See fixed sandbox: https://codesandbox.io/p/sandbox/router-jotai-forked-pj8nd8

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by foxaltus
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant