galio icon indicating copy to clipboard operation
galio copied to clipboard

Documentation on Switch component

Open levelingup opened this issue 4 years ago • 4 comments

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 avatar Jan 08 '20 17:01 levelingup

@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!

palingheorghe avatar Jan 09 '20 15:01 palingheorghe

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.

levelingup avatar Jan 10 '20 16:01 levelingup

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!

palingheorghe avatar Jan 13 '20 08:01 palingheorghe

Changing from onValueChange to onChange gives another error:

TypeError:_this2.toggleSwitch is not a function. (In '_this2.toggleSwitch("itemAvailable")', '_this2.toggleSwitch' is undefined)

anisharya16 avatar Apr 13 '20 16:04 anisharya16