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

Not able to update the state of single chat

Open Mavenic opened this issue 5 years ago • 1 comments

Issue Description

Adding chat messages by simply pushing them in GiftedChat works. But when I update single value in some chat (i.e sent = true), it doesn't reflect the change. Currently what i am doing to updated the chat messages is :

updateStateOfChat = chat => {
        this.setState(previousState => ({
            messages: GiftedChat.append( [], previousState.messages.map(m => {
                if (m.id === chat.id) {
                    return {...m, sent: chat.sent};
                }
                return m;
            }))
        }));
    };

Steps to Reproduce / Code Snippets

Call the setState on any chat.

Expected Results

It should re-render the chat message that is updated.

Additional Information

  • Nodejs version: 10.15.3
  • React version: 16.9.0
  • react-web-gifted-chat version: 0.6.7
  • Browser(s) (Chrome, etc.): Chrome

Mavenic avatar Oct 15 '19 05:10 Mavenic

Were you able to find a work-around for this? I looked through the code and couldn't find anyway to re-render the message.

leelandclay avatar Jul 08 '20 17:07 leelandclay