我正在创建一个反应原生聊天应用程序,但我无法在消息中获取用户名
// retrieve the messages from the Backend
loadMessages(callback) {
this.messagesRef = firebase.database().ref("messages");
this.messagesRef.off();
const onReceive = data => {
const message = data.val();
callback({
id: data.key,
text: message.text,
createdAt: message.createdAt,
user: {
_id: message.user._id,
name: message.user.Uemail,
avatar: 'https://placeimg.com/140/140/any',
}
});
};
this.messagesRef.limitToLast(20).on("child_added", onReceive);
}
renderUsernameOnMessage={true}