react-livechat icon indicating copy to clipboard operation
react-livechat copied to clipboard

Is this really React?

Open pmvald opened this issue 5 years ago • 3 comments

Reading the source code, I see that it does nothing but loading another js file (tracking.js) as a script to the page, and then this script adds html elements to the page to show the chat stuff. But this direct manipulation of the DOM is somehow against the react principal (?!). To make it really react, the whole chat frontend stuff (including the element generating code in tracking.js) should either become a react component, or a web component (that renders into the shadow DOM). The present implementation is not react.

pmvald avatar Aug 22 '21 21:08 pmvald

Agreed, the current code is not following react in any way.

biswajeet-cn avatar Aug 27 '21 06:08 biswajeet-cn

If we assume that all react frameworks/toolchains (create-react-app, gatsby, nextjs, etc) render the react stuff in a certain div element within the body, and assuming that this code (or better to say the tracking.js code) creates its element in a div right before the body, then there might be no conflict. But all these assumptions are just assumptions ... the safest way is that the chat stuff are rendered in a shadow DOM through some web component. Then there would be 100% no conflict with neither react nor any web component framework. The key is to avoid light DOM

pmvald avatar Aug 27 '21 16:08 pmvald

Hello 👋

I am happy to say that we have created a new set of packages to support more frontend frameworks integration with LiveChat Chat Widget: Chat Widget Adapters 🙂

Nor this repository nor the new one was never meant to provide a full implementation of the LiveChat Chat Widget for certain frameworks. The application is built and distributed by our company in form of installable widgets for websites and web apps and hosted from CDN. This and the new project of Chat Widget Adapters allow for easier integration in the project using certain frontend technologies as opposite to integrating it via HTML snippet code and Vanilla JS interactions with CW JS API.

We are more than eager to hear the feedback from you about the new implementation 🙌

walaszczykm avatar Jan 23 '22 13:01 walaszczykm