1

我正在创建一个反应本机聊天应用程序,但我无法在消息中获取用户名

  // 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);
  }
4

1 回答 1

1
renderUsernameOnMessage={true}
于 2019-05-28T16:04:18.500 回答