Repository navigation
Distinction between null value and removing parameter from URL
#1352
Unanswered
sherbakovSAF
asked this question in
Ideas
Replies: 1 comment
This is not possible to do with nuqs,
Then parseAsBoolean is likely not the right choice, unless the |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Current behavior
Currently, passing
nullto a setter removes the parameter from the URLand resets the state to its default value (if
.withDefault()is set).Problem
This conflates two completely different intentions:
null" → also resets to defaultThere is no way to distinguish between them.
Example:
I need three distinct states:
true,false, andnull(no filter applied).Right now that's impossible with a boolean parser because
nullis usedas the "reset" signal.
Possible solution
Would it make sense to use
undefinedfor removing a parameter from the URL,and allow
nullto be stored as a valid value? Or perhaps introduce a dedicatedAPI like
resetParam('isEnd')?Current workaround
Storing booleans as strings (
'true'/'false'/'null') viacreateParser,which defeats the purpose of typed parsers.
All reactions