Get single number from Shadcn UI slider for form?
I'm using Shadcn UI, React Form, and Zod for my Next.js project. I'm using the slider component on part of the form:
But the slider returns an array of values, even though I'm using only a single value. How do I get it to pass only that first array value to
I tried
I thought to make my own
Can you please help?
Thanks in advance!
But the slider returns an array of values, even though I'm using only a single value. How do I get it to pass only that first array value to
field.onChange?I tried
onValueChange={field.value[0] => field.onChange}, but that produces an error.I thought to make my own
handleFieldChange function to convert the array into a single number, but I couldn't figure out how to get the value back into the form.Can you please help?
Thanks in advance!
