galio
galio copied to clipboard
Documentation on Switch component
I noticed that if I just copy the code in: https://galio.io/docs/#/components/switch
<Switch
value={this.state["switch-1"]}
onValueChange={() => this.toggleSwitch("switch-1")}
/>
It throws an error saying that onChange is undefined. I think it would be a good to provide documentation that you would need onChange along with onValueChange. Unless I was implementing it wrong?
I was able to get my switch to work after adding onChange prop.
@levelingup have you tried using only onChange?
You're right, the example in our docs is not working correctly. We'd have to change that. This issue should be moved on our docs repo here: https://github.com/galio-org/docs
Thanks!
Yeah doing just onChange works, but it doesn't capture the value which I believe onValueChange is needed to do so, correct?
I'm still learning react native hehe.
We'll have to re-work this component for v1.0. Thank you for noticing that out! You're on the right path my friend!
Changing from onValueChange to onChange gives another error:
TypeError:_this2.toggleSwitch is not a function. (In '_this2.toggleSwitch("itemAvailable")', '_this2.toggleSwitch' is undefined)