OvidijusParsiunas / deep-chat

Fully customizable AI chatbot component for your website
https://deepchat.dev
MIT License
1.26k stars 170 forks source link

Chat Rerenders and React Hooks #218

Closed fragakos closed 1 week ago

fragakos commented 1 week ago

Correct me if I am wrong, but when I use any hook that triggers a rerender, the chat loses its history, but only the one that is showing, the actual history is still stored, how to overcome this?

OvidijusParsiunas commented 1 week ago

Hi @fragakos.

If the component that Deep Chat is defined in gets re-rendered then then the Deep Chat element will indeed be reinitialised from scratch along with its history.

I am not sure what you mean by the actual history is still stored as the state in Deep Chat is refreshed.

This problem can be overcome by storing the messages inside an external state. This has been explained in more detail in the following issue and any further questions in regards to React re-renders should be addressed there.

Thankyou!