I have a list of items. users can like them. I use AsynStorage to store the state. It works. Only, I can't bind the storage to a specific item. If I like/dislike an item, the same thing happen for all of them. Here is the code, an idea ?
componentWillMount() {
this._renderSwitchButtonWithAsyncStorage().done;
}
_renderSwitchButtonWithAsyncStorage = async() => {
let token = await AsyncStorage.getItem('AlreadyLiked');
if (token){
this.setState({trueSwitchIsOn: true});
}else{
this.setState({trueSwitchIsOn: false});
}
};
onPressIcon(word){
AsyncStorage.setItem('AlreadyLiked', JSON.stringify({trueSwitchIsOn}));
}
Use Different AsyncStorage key name, If you use same name to affect the all users so each users has use different key