ui
ui copied to clipboard
onChange event is not getting triggers in <Slider /> component
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}
/>
Try onValueChange.
https://www.radix-ui.com/docs/primitives/components/slider#api-reference
It worked. Thanks.
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
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 ☺️