4

enter image description hereIt looks like this is my backend for the chat messaging app any idea of this problem? I wanted to display the name of who chatted me

 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,
        }
      });
    };
Allen Cris
  • 109
  • 3
  • 11

2 Answers2

4

You can use renderUsernameOnMessage props for this.

Doc : renderUsernameOnMessage (Bool) - Indicate whether to show the user's username inside the message bubble; default is false

In other hand you can customize this component and change whatever you want! maybe related to this

Mohsen
  • 1,415
  • 1
  • 13
  • 26
0

you nee to pass props renderUsernameOnMessage={true} and pass name inside user

in my case

  <GiftedChat
                messages={messages}
                onSend={messages => onSend(messages)}
                renderAvatar={null}            // remove avtar
                renderUsernameOnMessage={true} // default is false
               user={{
                    _id: userId,
                    name:name                  // display name
                }}
            />
Paresh Shiyal
  • 534
  • 4
  • 15