react-native-material-kit icon indicating copy to clipboard operation
react-native-material-kit copied to clipboard

MKSwitch dont change while use setState in onCheckedChange

Open dlehdanakf opened this issue 7 years ago • 3 comments

Hi, I have written the code below.

<MKSwitch
    onCheckedChange={(e) => {this.setState({searchWithCategory: true})}}
/>

But it dosen't change though I pressed the switch button. It works when I put function like console.log, but this.setState is not. Is there any solution to work with this.setState function?

npm Version : 4.6.1 RN Version: 0.46.4 RNMK Version: 0.4.1 using Android.

I would be grateful if you could show me how to fix this problem.

dlehdanakf avatar Aug 10 '17 08:08 dlehdanakf

Someone fixed this?

for now the only way to make this work is using a workaround and putting a setTimeout of 250 to wrap the setState :(

Tamiyadd avatar Oct 23 '17 14:10 Tamiyadd

I found another way

<MKSwitch
    checked={this.state.checked}
    onCheckedChange={(e) => {
    this.setState({
        checked:e.checked === true
    });
}}/>

but animation will gone

deadmerc avatar May 12 '18 12:05 deadmerc

Nothing yet????

forster-thomas avatar Sep 30 '18 06:09 forster-thomas