反应本地聊天呈现用户名

时间:2019-02-09 06:49:43

标签: react-native react-native-gifted-chat

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

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

1 个答案:

答案 0 :(得分:0)

renderUsernameOnMessage={true}