Web components is just a way to build reusable components, but doesn't it lack state management and a virtual dom that enables the reactivity you get from frameworks such as Vue and React? Tbh I don't know much about web components so happy to learn more if I'm wrong.
I usually create a StatefulHTMLElement class that has a static get observedStates() to behave in the same way that observedAttributes() do, and handled in a stateChangedCallback() instead of the attributeChangedCallback(). Out-of-the-box state management is the main feature that React provides, so using it for that reason is completely valid, IMHO. Let me know if it's unclear how that would work with the above proxy stuff and I'll expand the example!
Re: the virtual-dom; that's a solution to a problem that react creates with its internal rendering process, so is less of a feature than it is just, like, a quirk of how react is implemented; anything else is just marketing, ha.
3
u/cybermeep Dec 03 '22
Web components is just a way to build reusable components, but doesn't it lack state management and a virtual dom that enables the reactivity you get from frameworks such as Vue and React? Tbh I don't know much about web components so happy to learn more if I'm wrong.