3 ms·
Webcomponents are a huge mess, caused partially because it requires to do (some) composition in html. React is much simpler, it uses basic html elements (div, i
by javitury 5y ago
Webcomponents are a huge mess, caused partially because it requires to do (some) composition in html. React is much simpler, it uses basic html elements (div, input, ...) and event apis to compose an application in javascript.
These are some disadvantages of webcomponents that I can think of.
- Can't register multiple versions of a webcomponent. Let's say you are using "x-dropdown"@2.0.0 which depends on " x-icon"@2.0.0 and "x-menu"@3.0.0 which depends on " x-icon"@1.0.0. Your app will crash because html tags can't have multiple versions ("x-icon" 2.0.0 and 1.0.0). It makes handling big projects a nightmare. And there are name collisions too.
- Not all properties can be serialized into attributes as strings, so you end up just binding properties. Boolean attributes have special are weird when used in the javascript side (an empty string is treated as a boolean)
- The shadow dom can be too restrictive and inflexible. Implementing portals for instance, requires using ugly hacks that depend on your webcomponent framework.
- Some complex webcomponents are not interoperable among different frameworks.
- Static analysis on webcomponents is poor and fragile. Compare declaring types of events in webcomponents, to declaring types of event handlers in react.
- azangru 5y agoYoutube's website is built with web components (used to be Polymer, but I wonder if they haven't migrated to lit by now). Seems to be working fine for a large-scale project like theirs. Chrome Dev Tools are also, at least in part, built with web components.
- dmitriid 5y ago> Seems to be working fine for a large-scale project like theirs. It's not web components that were working for them at scale, but Polymer. They would've probably nebver completed anything with Web Components alone due to how horrendously bad their API is. You can compare Web Components API and Polymer API here: https://twitter.com/dmitriid/status/865518972380237825 https://twitter.com/dmitriid/status/865518972380237825 It still took them over two years to switch from Custom Elements v0 to Custom Elements v1.