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

Not disabled completely when disabling #5

Closed jimitpatel closed 6 years ago

jimitpatel commented 6 years ago
import SwitchButton from 'react-switch'
<SwitchButton disabled=false height={20} width={48} className='react-switch' id='material-switch' />

Even though it is disabled, when I am dragging it, it is still working, but when I am clicking it, it is not working.

markusenglund commented 6 years ago

I see two issues with the code sample that you've provided:

  1. You're not giving the switch a checked and onChange prop. Both of these are required for it to work properly.
  2. You've set disabled to ´false´. That means the switch is not disabled. You should set disabled to ´true´ to disable the switch.

If you fix these things, I'm sure the package will work as advertised.

jimitpatel commented 6 years ago

Cool. Understood my problem. Although, above code was just a part of it. I messed with flag values for disabled and was changing it to check or uncheck on clicking it. Thanks a lot