React native 无法从媒体上获取数据
无法在onPress中获取数据,但它在视图中显示数据如何 正在尝试获取item.cash控制台.log(item.cash)的值0 但在我们看来,这是500英镑 非常新,请帮助我理解数据流React native 无法从媒体上获取数据,react-native,react-native-android,React Native,React Native Android,无法在onPress中获取数据,但它在视图中显示数据如何 正在尝试获取item.cash控制台.log(item.cash)的值0 但在我们看来,这是500英镑 非常新,请帮助我理解数据流 _renderItem({item, index}, parallaxProps) { const { rewardRedemptions } = reference.RewardRedemptionReducer; return ( <Tou
_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}*
</...>
);
}
\u renderItem({item,index},视差){
const{rewardRedemptions}=reference.RewardRedemptionReducer;
返回(
{
var cashAmt=parseInt(项目.现金);
如果(现金金额==0){
返回;
}
**控制台.日志(项目.现金);
log(parseInt(item.cash))**
>
\u renderItem({item,index},视差){
const{rewardRedemptions}=reference.RewardRedemptionReducer;
**控制台.日志(项目.现金);
log(parseInt(item.cash))**
返回(
log(parseInt(item.cash))}->试试这个
>
onPress在哪里?抱歉,现在已编辑。顺便说一句,您可以看到它已修复。它放在return语句中时可以工作
_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}*
</...>
);
}