ui icon indicating copy to clipboard operation
ui copied to clipboard

onChange event is not getting triggers in <Slider /> component

Open abhinav-anshul opened this issue 2 years ago • 1 comments

Hi,

I'm using <Slider /> component in Next.js 13, unless I'm doing something really wrong, the <Slider /> component is not logging the current value when I'm passing the onChange handlers like :

 <Slider
   onChange={(i) => console.log(i)}
   // defaultValue={[33]}
   max={100}
   step={1}
/>

abhinav-anshul avatar Apr 15 '23 12:04 abhinav-anshul

Try onValueChange.

https://www.radix-ui.com/docs/primitives/components/slider#api-reference

shadcn avatar Apr 15 '23 15:04 shadcn

It worked. Thanks.

abhinav-anshul avatar Apr 26 '23 11:04 abhinav-anshul

Try onValueChange.

https://www.radix-ui.com/docs/primitives/components/slider#api-reference

Thank you it helped me alot! I did onchange that's why it's not working :D

grayhams74s avatar Feb 26 '24 07:02 grayhams74s

first do this before return...

const [val, setVal] = useState([50]);
console.log("🚀 ~ page ~ val:", val[0])

then do this

<Slider defaultValue={val} max={100} step={1} onValueChange={(i) => setVal(i)} />

You will see your value on console ☺️

nisharga avatar May 19 '24 05:05 nisharga