nettofarah / react-flexible-switch

:on: Easy and Flexible React Switches
http://nettofarah.github.io/react-flexible-switch
54 stars 14 forks source link

Usable as a controlled/uncontrolled component #8

Closed ThariqS closed 7 years ago

ThariqS commented 8 years ago

I love the UI options and customizability with this component. It would be great if it could follow the React standards for input/form elements though: https://facebook.github.io/react/docs/forms.html

Basically either having the ability to pass in a value and make in a controlled component, or use a defaultValue and then be able to do something like this.refs.switch.value to get the value of the component.

nettofarah commented 8 years ago

hey, @ThariqS. That's a great idea! Definitely something we can work on.

Just so you know, the way I currently simulate this behavior is through the onActive and onInactive callbacks the component provides. I keep the switch state as a property of the parent component's state and update it with these two callbacks.

Do you want to take a stab and submit a PR?

nettofarah commented 7 years ago

Fixed by #11.