-
It's possible to implement a custom parser for a single key, but sometimes it is super handy to have a parser that transforms values from multiple keys together into the desired format. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Do you have an example? You can kind of get there with const searchParamsParsers = {
page: parseAsInteger.withDefault(1),
modalOpen: parseAsBoolean.withDefault(false),
search: parseAsString
}
const [{ page, modalOpen, search }, updateSearchParams] = useQueryStates(searchParamsParsers)
const nextPage = () => updateSearchParams(state => ({
page: state.page + 1
// Partial update: other search params keep their values
})) One downside to this is that every key is parsed individually. It would not help in cases where you need key |
Beta Was this translation helpful? Give feedback.
Do you have an example?
You can kind of get there with
useQueryStates
, and declaring an object of parsers for the individual keys:One downside to this is that every key is parsed individually. It would not help in cases where you need key
foo
to have a particular set of values whenbar
has a specific value. Adding a…