markusenglund / react-switch

A draggable toggle-switch component for React. Check out the demo at:
https://react-switch.netlify.com/
MIT License
1.33k stars 100 forks source link

"onChange is not a function" #118

Open Redblock6YT opened 2 years ago

Redblock6YT commented 2 years ago

I'm using nextjs and when I click the switch this is the error I get: image Here's my code: <label> <span>Switch with default style</span> <Switch onChange={handleChange(1)} checked={isActive(1)} /> </label>

markusenglund commented 2 years ago

It looks like you're invoking the handleChange function which means you're passing whatever that function returns to the Switch component. You should be passing the function itself.