Wolox / react-chat-widget

Awesome chat widget for your React App
MIT License
1.45k stars 458 forks source link

Re-rendering all messages when a new message is added #67

Open noalevit18 opened 6 years ago

noalevit18 commented 6 years ago

Hi, While debugging I added console logging in the render function of multiple components. Suppose every component is rendering the other via "renderCustomComponent". When the 2nd component is rendered, the 1st component is also rendered, when the 3rd is rendered, the 1st and 2nd are also rendered and so on. The 10th component will re-render all the previous 9 components.

I looked at the source code and in the render function of your messages component (src/components/Widget/components/Conversation/components/Messages/index.js) you re-render all the messages in the store I suppose that re-rendering all the messages is relevant in case you minimize the chat window, but it can cause performance issues in case you're just willing to add 1 message. The number of messages in the chat keeps growing, which means the performance will keep droping.

mcallegari10 commented 6 years ago

Hi @noalevit18 thanks for the heads up! We'll look into that performance issue as soon as we can 😄

jiaqihuangrerere commented 6 years ago

It is possible to add the remove function to remove all the message at once?

sahar922 commented 5 years ago

It is possible to add the remove function to remove all the message at once?

already exist, dropMessages()

snetts commented 5 years ago

How do I activate the re-rendering of previous messages? When a user refreshes the page all the chat disappears and I want to keep it until the user decides to clear it using a button.

manthanbaranwal commented 2 years ago

Hey @mcallegari10 , we are still seeing this issue. Can you please tell us when can expect the fix?