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

Ignore filter Default value #542

Open
ariel-upstream opened this issue May 15, 2023 · 8 comments
Open

Ignore filter Default value #542

ariel-upstream opened this issue May 15, 2023 · 8 comments

Comments

@ariel-upstream
Copy link

Is It possible to pass a parameter in the URL of some empty/null/undefined value so the default value will be ignored?

@xiel
Copy link
Owner

xiel commented May 15, 2023

mhh can you give an example? what would be returned in that case?

@ariel-upstream
Copy link
Author

For example:
In Home page: const [emails, setEmails] = useQueryState<string[]>("emails", ["a@gmail.com"])
now I want to navigate from another page to my Home page but without the default email filter
I will try something like:
navigate("home#emails: []") but I will get the filter with the "a@gmail.com" value
Is it possible to pass some value(e.g.: null, explicit empty array) that will ignore the default filter value?

@xiel
Copy link
Owner

xiel commented May 15, 2023

When you call setEmails([]) you will get the link you are looking for :)

#emails=%5B%C2%A0%5D

@ariel-upstream
Copy link
Author

ariel-upstream commented May 15, 2023

I don't have access to setEmails from another page, can I do it from the URL? I tried:
navigate({ pathname: "/home", hash: createSearchParams({ emails: [], }).toString() })
also tried: navigate("/home#emails=%5B%C2%A0%5D")

and I still get the default filter in the state of emails

@xiel
Copy link
Owner

xiel commented May 15, 2023

Can u please try to navigate using a normal anchor? (to href= home#emails=%5B%C2%A0%5D)

Maybe the hash update does not correct coming from this navigate fn? where does it come from?

@ariel-upstream
Copy link
Author

It's react-router-dom useNavigate hook

@xiel
Copy link
Owner

xiel commented May 16, 2023

did you try using a normal link <a href="..." />?

@ariel-upstream
Copy link
Author

Not yet, bet anyway it's not aligned with my code convention

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