react-web-gifted-chat icon indicating copy to clipboard operation
react-web-gifted-chat copied to clipboard

renderUsernameOnMessage didn't work

Open barak109 opened this issue 4 years ago • 1 comments

Issue Description

Hi, i really love the way you update this react native app to be a web app- thank you for that !

My problem is when i tried to show username in the messages, and it didn't work.

Steps to Reproduce / Code Snippets

I used

  renderBubble = (props: any) => {
    return (
        <Bubble renderUsernameOnMessage {...props}></Bubble>
    );
  };

And add it to GiftedChat and still didn't work, i think it's a bug

Expected Results

See the userName in messages

Additional Information

  • Nodejs version: [12.18.1]
  • React version: [16.3.1]
  • react-web-gifted-chat version: [last- ^0.6.7]
  • Browser(s) (Chrome, etc.): [Chrome]

barak109 avatar Aug 04 '20 08:08 barak109

I ran into the same problem. The way I resolved it was to modify the props of the bubble directly by adding a renderBubble={this.renderBubble} to the GiftedChat object. Then added this method to my class:

protected renderBubble = (props: BubbleProps<IMessage>) => {
props.renderUsernameOnMessage = true;
return <Bubble {...props} />;
};

leelandclay avatar Aug 07 '20 20:08 leelandclay