react-native-material-kit
react-native-material-kit copied to clipboard
MKSwitch dont change while use setState in onCheckedChange
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.
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
:(
I found another way
<MKSwitch
checked={this.state.checked}
onCheckedChange={(e) => {
this.setState({
checked:e.checked === true
});
}}/>
but animation will gone
Nothing yet????