Skip to content
Discussion options

You must be logged in to vote

The general recommendation would be to define a search params descriptor object that contains both the keys & associated parsers with their default values, which would look like what you have. For example:

export const profileExplorerSearchParams = {
  dashboard_items: parseAsNativeArrayOf(parseAsString).withDefault(['flamegraph'])
}

// Usage:
const [{ dashboard_items }, setSearchParams] = useQueryStates(profileExplorerSearchParams)

// You can also derive other things from this object, like a loader for one-time parsing:
const loadProfileExplorerSearchParams = createLoader(profileExplorerSearchParams)
// Or a link generator:
const getProfileExplorerHref = createSerializer(profileExplore…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by manojVivek
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants