我正在尝试使用 AsyncStorage 将 prop.id 与购买的商品列表进行比较。
试图做到这一点...
state = {
hidePrice: { width: 100, height: 150 }
}
render(){
return this.props.property.map(( prop ) => (
<View key={ prop.id }>
<View style={[ this.state.hidePrice, {} ]}>
<Text>!!! Purchase Price Goes in here !!!</Text>
</View>
</View>
));
}
做这样的事情...
getPurchasedItems = async() => {
try{
const purchases = await AsyncStorage.getItem( purchaseID );
purchases.forEach(purchase => {
if ( purchase.purchaseID === prop.id ){
this.setState({ hidePurchase: { width: 0, height: 0 } });
} else {
this.setState({ hidePurchase: { width: 100, height: 150 } });
}
})
} catch( err ){
Alert.alert( err.message );
}
}