Isomorphic Reagents or Web Components (Polymer) Which one should a developer follow?
Over the years, we have seen many removal technologies for web development, for example:
Isomorphic React:
It provides a common code base shared between client and server.
Web Components:
Polymer.js shows a way to create a custom browser element.
Both of these technologies go in the opposite direction. What should be a web developer? Any suggestions and comments are welcome here.
source to share
React and Web Components are similar, but not the same. What's great about web components (or at least the idea, we're not quite there yet) is that you should be able to extend HTML with custom elements. The browser won't give you the element <datepicker>
? Throw the web component that implements it! You don't have to worry about how it is implemented, you just import it and then you can use it. Turns out it has low availability or low browser support? Someone else has probably created something better.
The big problem with web components nowadays is that they add global names. So if there is ever a de facto web component registry like NPM for Node, you will be in a race for better names. But with NPM this is not a huge problem, because you can name the variable whatever you want, for example var Promise = require('bluebird');
. He tells you what he is doing. But a web component with a name blue-bird
would be terrible since you won't know what it does when you read the markup that uses it. So if this isn't fixed before the web components are final, we'll end up with long, prefixed, wierd names to avoid naming conflicts.
Web Components are designed for small components that are fairly general. Things like date picker, autocomplete picklist, map item, etc. They are not intended to address how you structure your application, but instead how we can reuse common elements between sites. This way you can see custom elements such as <date-picker>
, but you will not see index.html
only with <body><my-app></my-app></body>
, where my-app
is the web component for your specific application. Well, maybe you'll see it, but that's not really the purpose of web components, and it doesn't give you a lot of options for that.
React, on the other hand, is all about how you structure your application and pass data between your components. You can pass simple Javascript objects as properties to React components, but the only thing you can pass as an attribute to a web component is a string. Which works for simple things, but not for your entire application.
They are not mutually exclusive as you will likely see a lot of people using web components in their React apps. But if you see someone building a web component that depends on React, feel free to yell at them. Web components are supposed to be isolated and reusable, and including a large library / framework like React inside one is an anti-pattern.
source to share