无法在onPress中获取数据,但如何在视图中显示数据?
试图获取item.cash console.log(item.cash)获得值0 但鉴于它是500。
对本机有新的反应,请帮助我了解数据流。
_renderItem({item, index}, parallaxProps) {
const { rewardRedemptions } = reference.RewardRedemptionReducer;
return (
<TouchableOpacity
onPress={() => {
var cashAmt = parseInt(item.cash);
if (cashAmt == 0) {
return;
}
**console.log(item.cash);
console.log(parseInt(item.cash));**
>
<Text
style={{
fontSize: Dimens.twentyThree,
color: Colors.white,
fontFamily: Fonts.SourceSansProSemibold,
}}
*children={item.cash}*
</...>
);
}
答案 0 :(得分:1)
_renderItem({item, index}, parallaxProps) {
const { rewardRedemptions } = reference.RewardRedemptionReducer;
**console.log(item.cash);
console.log(parseInt(item.cash));**
return (
<TouchableOpacity
onPress={()=>console.log(parseInt(item.cash))} ---> try this
>
<Text
style={{
fontSize: Dimens.twentyThree,
color: Colors.white,
fontFamily: Fonts.SourceSansProSemibold,
}}
*children={item.cash}*
</...>
);
}