我无法从我的阵列中访问对象的属性。
这是我的代码:
{
this.props.viewer.messagesByUser.edges.map(edge => {
console.log("chatFriendPopPup id = ", chatFriendPopPup.id)
console.log("receiver['_id'] = ", edge.node.receiver['_id']) // returns undefined
console.log("receiver._id = ", edge.node.receiver._id) // returns undefined
console.log("receiver._id = ", edge.node.receiver)
if (edge.node.receiver._id.toString() === chatFriendPopPup.id.toString()) {
return <li > {
edge.node.body
} - seen: {
edge.node.seen
} < /li>
}
})
}
Receiver有这样的属性,但我无法获得._id
{
_id: 597 f7eb1e5131d5a50e18d14,
updatedAt: 2017 - 07 - 31 T19: 02: 09.035 Z,
createdAt: 2017 - 07 - 31 T19: 02: 09.035 Z,
fullName: 'ria atayde',
email: 'myloves@gmail.com',
}