将地图属性与AsyncStorage项进行比较

时间:2019-05-17 12:26:50

标签: react-native in-app-purchase android-inapp-purchase

我正在尝试使用 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 );
  }
}

0 个答案:

没有答案