我正在创建一个本机响应聊天应用程序,但无法在消息中获取用户名
// 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);
}
答案 0 :(得分:0)
renderUsernameOnMessage={true}