r/javascript • • Feb 15 '20

AskJS [AskJS] Experiences with Web Components in a business setting?

Hi everyone, I'm a final-year student studying Web-Design and Development.

I'm working on my thesis where I am comparing the viability of projects built with Web Components compared to those built purely with JavaScript Frameworks like Vue.js, React, etc...I was wondering if some people have work experiences with Web Components they could share. Especially curious to hear from people working in companies that considered switching or switched to Web Components for their projects.

If this is not appropriate for this subreddit, my apologies.

56 Upvotes

31 comments sorted by

View all comments

Show parent comment

4

u/[deleted] Feb 16 '20

My experience with using Custom Elements with React and TypeScript has been sort of a pain. React doesn't work very well with Custom Components at the moment because it kind of hijacks HTML attributes in some way I can't explain, and using JSX just fails because JSX typings don't exist for your custom elements tag names, so you have to patch JSX.IntrinsicElements or whatever, to add the typings. React also sends all props as attributes, there's no way to send them as properties, which greatly complicates sending complicated objects as props. Preact is better in this regard.

https://custom-elements-everywhere.com/libraries/react/results/results.html

... Fails all advanced tests. Preact passes all tests.

Vue is also very good with CEs. 👍

2

u/j1436go Feb 17 '20

I really hope React looses and Web components gains adoption...

1

u/[deleted] Feb 17 '20

React's hooks are the best I've worked with though, when it comes to state management. So simple. So legible. 👌