-
-
Notifications
You must be signed in to change notification settings - Fork 135
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
feat: Add "clear on default" option #493
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the naming of the option itself (which is hard to convey while keeping it short), one nitpick I may have with this implementation is that it's possible to specify clearOnDefault
while not having set a default value, for which it will not do anything.
useQueryState('foo', parseAsInt.withOptions({
clearOnDefault: true
})
But then again, the intent is clear, and the alternative would require a large refactor of the type system. This will probably happen in v2.
🎉 This PR is included in version 1.17.0-beta.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
🎉 This PR is included in version 1.17.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Good addition to the package! FYI use-query-params which I always used for SPAs and Next Page Router has this option as well. There it's called removeDefaultsFromUrl. |
@rwieruch good catch, thanks! I'll update the docs to make the connection (since it's been released into stable, it's a bit late to change the name). |
Adds an option to remove the key-value pair when setting a state to the default value. Default behaviour remains to keep it explicitly set in the URL, for backwards-compatibility when defaults change.
Closes #320.
Closes #488.
Closes #490.