Closed oluvvafemi closed 2 months ago
Hey @oluvvafemi.
This is a standard React practice as changing the state of a component will automatically re-render all of the elements (including Deep Chat) inside it - as well as its message state. The current best solution at the moment is indeed storing the relevant state such as messages inside external state such as an external variable, browser storage, state library or cache. (The DeepChat Playground uses localstorage to retain all data during re-renders and persist it through multiple client sessions, code here)
Looking into the future, I am very inclined to create a solution that would allow the storage of state through configuration so that devs would no longer need to worry about integrating solutions for their state. I have to get through a couple of features before I can get to that one, but I am very committed to exploring it.
If you have any further questions regarding this let me know. Thanks!
Thank you @OvidijusParsiunas.
Anytime I set state in React, for example in responseInterceptors, I lose the message and the component rerenders.
For some cases, I set a global variable as a workaround. But is there a solution for when you really need to set a state.