以下是对象
Object {
"index": 0,
"item": Object {
"-1509965540253": "Hey Blade Runner!!",
"fName": "Gaston Day Public School",
"fromName": "Gaston Day Public School",
"message": "HEy ! Full metal jacket !",
"time": -1509967894467,
},
"separators": Object {
"highlight": [Function highlight],
"unhighlight": [Function unhighlight],
"updateProps": [Function updateProps],
},
}
我想在以下功能中访问fromName
renderInboxList= (item) =>{
console.log("FromName",item.fromName);
return (
<TouchableOpacity key={item.fromId} onPress={() => {console.log("TOmoving to chat thread");navigate('ChatThread', { fromId: `${l.fromId}` });}}>
<ListItem
key={item.fromId}
leftIcon={{ name: 'user-circle-o', type: 'font-awesome', style: {color: 'blue'} }}
title={item.fromName}
titleStyle={{color: 'red'}}
subtitle={item.message}
rightTitle={item.time}
rightTitleStyle={{color: 'green'}}
/>
</TouchableOpacity>);
}
item.fromName
给了我undefined
。
答案 0 :(得分:0)
请使用:
var fromName = item.item.fromName;