Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does he work? #2

Open
vaynevayne opened this issue May 16, 2023 · 1 comment
Open

How does he work? #2

vaynevayne opened this issue May 16, 2023 · 1 comment

Comments

@vaynevayne
Copy link

When I changed the value, I found that the url had not changed, but when the page was refreshed, the value was still there, and neither session nor local strorage saw it.
Excuse me, where is the value stored?

@nitedani
Copy link
Owner

nitedani commented May 17, 2023

The values are stored in the address bar as a query parameter. When you change a value in the store, then it should change the url in the address bar only if that specific value is selected to be persisted for the page (select option).

For example - if your select looks like select(pathname) { return { count: "/items" === pathname }} then the middleware will only work on that single /items page, storing the count in the url. If you go to /apples page, then the middleware won't load count from the url.
You can try returning something like { count: true } in select and see if it fixes the issue.

If it still doesn't work and you would like me to fix the issue, please create a reproduction on stackblitz/post your store configuration.
You can create a reproduction based on this one: https://stackblitz.com/github/nitedani/zustand-querystring/tree/main/examples/react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants