【发布时间】:2019-04-01 08:28:04
【问题描述】:
我正在使用 react-native-gifted-chat(https://github.com/FaridSafi/react-native-gifted-chat) 在我的应用程序上创建聊天界面,我想从我的数据库中加载消息,但是如何在 react-native-gifted-chat 中指定它接收者发送消息而不是发送者,即在应用加载之前,消息被加载到this.state.messages,根据文档,应该是这样的
{
_id: 1,
text: 'My message',
createdAt: new Date(Date.UTC(2016, 5, 11, 17, 20, 0)),
user: {
_id: 2,
name: 'React Native',
avatar: 'https://facebook.github.io/react/img/logo_og.png',
},
image: 'https://facebook.github.io/react/img/logo_og.png',
// Any additional custom parameters are passed through
}
文档只说明了如何指定发送者的消息,没有说明接收者,请问如何显示接收者的消息,即
{
_id: 2,
text: 'Receiver's message',
createdAt: new Date(Date.UTC(2016, 6, 11, 17, 20, 0)),
user: {
_id: 2,
name: 'Receiver',
avatar: 'https://facebook.github.io/react/img/logo_o3.png',
},
image: 'https://facebook.github.io/react/img/logo_o3.png',
}
【问题讨论】:
-
消息对象的“user”键中的键“_id”应该不同。
标签: android reactjs react-native state