我想保存开关按钮状态,这样用户就不能投票两次。我有一条消息错误:在目标 AsyncLocalStorage 上调用 multiSet 时抛出异常'-[NSDictionaryM 长度...有什么想法吗?
this.state= {
trueSwitchIsOn: false,
};
onSwitchChange(_key){
const{trueSwitchIsOn}=this.state;
switch (this.state.trueSwitchIsOn){
case false:
return(
<TouchableHighlight onClick={this.onPressIcon(_key)}>
{this.setState({trueSwitchIsOn: true})}
</TouchableHighlight>
);
case true:
return(
<TouchableHighlight onClick={this.onUnPressIcon(_key)}>
{this.setState({trueSwitchIsOn: false})}
</TouchableHighlight>
);
}
}
onPressIcon(word){
AsyncStorage.setItem('AlreadyLiked', {trueSwitchIsOn});
const{trueSwitchIsOn}=this.state;
this.setState({trueSwitchIsOn : true});
}
onUnPressIcon(word){
AsyncStorage.setItem('NotAlreadyLiked', {trueSwitchIsOn: false});
const{trueSwitchIsOn}=this.state;
this.setState({trueSwitchIsOn : false});
<Switch>
onValueChange={(value)=>this.onSwitchChange(_key)}
</Switch>