2 ms·
IMO the main reason more people aren’t using Web Components is because React doesn’t support them. Preact does it just fine so I have to assume it’s possible b
by afavour 3y ago
IMO the main reason more people aren’t using Web Components is because React doesn’t support them.
Preact does it just fine so I have to assume it’s possible but simply not in the interests of the React team. React feels like the enterprise lock-in of 2020s development: if you use it you’re using it top to bottom and it’s very difficult to mix and match with other frameworks. It’s a shame.
- coldtea 3y agoNobody (meaning very few) care for Web Components, React or not. Even in frameworks that do support them, they're just not widely used.
- afavour 3y agoWeb Components are just an API, a means to an end. You might as easily say nobody cares for document.createElement() but it’s still used by underlying code all the time. If it were much easier to mix and match components that use different frameworks then people would be using web components whether they know it or not. But we’re in a React monoculture and React folks seem quite content with that.
- wokwokwok 3y agomm... Web components aren't 'an' api, it's a specific way of using a set of apis, and specifically requires you to use a set of templates in a way that frameworks (which looovvvveeee DSLs) won't accept. The other bits? shadow dom? Custom elements? eh. Those are things a framework will wrap happily enough if they see value in it. Maybe some already do? As you say, you'd never know... ...but those html templates will never fly. They're just crazy bad ergonomics and framework authors will never accept them. That's really the core of the issue; invoking components in your layout requires you to use some kind of layout template, and every framework does it differently. That's why cross framework css solutions (eg. tailwind) are massively successful, because they can be called easily by anyone regardless of the templating; the same is not... and, frankly, seems like it never will, be true of web components.
- zelphirkalt 3y agoThey shouldn't be called web components in React (typical JS world term squatting). Instead they should be called React Components.
- coding123 3y agoI personally think more people aren't using WC because React simply exists. I know that sounds controversial, but it isn't. https://2022.stateofjs.com/en-US/libraries/ https://2022.stateofjs.com/en-US/libraries/
- racedude 3y agoWhere do you see React doesn’t support web components?.. also many frameworks have wrappers around web components specifically for frameworks like Vue and React for things like passing other values than strings.
- pjmlp 3y agoIn Angular and Vue, their component model nowadays can be mapped into web components directly, it is only a matter of configuration. React pretends they don't exist.
- dannye 3y agoReact supports Web Components, just some quirks to be aware of: https://custom-elements-everywhere.com/ https://custom-elements-everywhere.com/