Skip to content

Is there any way to get Numbers which i pass on parseAsNumberLiteral method ? #518

Answered by franky47
Kavan72 asked this question in Q&A
Discussion options

You must be logged in to vote

You could export the options if you need them at runtime somewhere else, that's how I do it:

// searchParams.ts
export const diceValues = [1, 2, 3, 4, 5, 6] as const
export const diceParser = parseAsNumberLiteral(diceValues)

// component.tsx
import { diceValues } from './searchParams'

for (const faceValue of diceValues) {
  ...
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Kavan72
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants