React has become one of the top frameworks (I mean libraries) based on the following promises. React is fast, it allows developers to create reusable components, it is not opinionated, and it is fun and easy according to its creators.
See the videos Rethinking Best Practices
https://www.youtube.com/watch?v=x7cQ3mrcKaY&ab_channel=JSConf and
https://www.youtube.com/watch?v=DgVS-zXgMTk. This sounds great, sign me up.
The reality is that React failed to live up to any of these promises. The virtual DOM takes a lot of memory and the diffing process requires 2 virtual DOMs which is a huge memory hog. It also is slow to load and if you open multiple instances of the same website, which many people commonly do, you have to download the whole React app for each tab.
Numerous studies have shown that web pages built in web components significantly out perform the same page built using React. Part of the reason this is the case is that web components do not use a virtual DOM. They interact with the DOM directly and they are built into the W3C specification so they work natively with browsers. Web components are fast, unlike React.
React promises that it has reusable components. This sounds great, but the reality is that React components can only be reused in other React applications. Not only that, but even reusing React components requires a lot of rewiring. At the least you have to reset up the passing of props and functions for the new app.
Web components are reusable just like any other web component, such as the
tag or a or. So web components can be used in React apps, Angular, Vue, Rails, or in an app that is not using any framework.React has consistently claimed that it is not opinionated. But anyone who has tried to build anything real with React knows this is a blatant lie. The only sense in which this statement is true, is that you can probably use any backend database technology with React. However, React completely takes over every thing else. Examples of this can be found in numerous questions on Stackoverflow. The answer is almost always to rewrite a solution from another technology.
Web components can be used with any backend or frontend technology including React.
The last big claim is that React is fun and easy. This is complete marketing hype. React has its own DSL (Domain Specific Language), it is wordy (not DRY), and is not intuitive. React is like a child who only a mother could love. I cannot say you will find Web Components as fun and easy, but it works the same way browsers work. So it is the opposite of a DSL and very useful to learn.
React failed to live up to any of its initial promises, however Web Components do.
Top comments (0)