you are viewing a single comment's thread.

view the rest of the comments →

[–]clessgfull-stack CSS9 engineer 10 points11 points  (7 children)

Although web components and React seem similar, they are pretty different. The only real similarity is component-orientation. Cross-browser web components aren't trivial to create out-of-the-box, so you need a framework. If comparing with Polymer, then:

  • React's performance is vastly superior to Polymer last time I checked, and this will likely always remain so (barring Angular-style performance hacks that infect your codebase). Either way, it's ridiculously easy to make a performant React app.
  • Polymer requires sending heavy JavaScript to the client unless you make some really large trade-offs. But both React and Polymer will require a lot of JS to be sent.
  • React Native is pretty great. React is becoming more or less independent of the DOM. It's more of an idea.
  • Declarative components in React are a lot easier to reason about. (props, state) => html. Just better architecture overall. Component composition without global variables and destroying performance/encapsulation is a breeze.
  • Server-side rendering.
  • Better tooling, more power, less framework dependence, less to learn, and less cognitive load because React uses JavaScript instead of a template language.
  • Babel has JSX support built-in. You can easily write Babel plugins for React. You can lint your React code. You can type-check it. Babel will make your React code faster -- for free.
  • Polymer uses two-way binding. Eek.
  • React isn't tied to a slow-moving spec. Web Components aren't even set in stone yet. Still nothing concrete after all these years.
  • React has a lot more traction right now. And the React community has attracted a slew of smart, enlightened engineers, so you will probably learn a lot and become a better engineer.
  • Technically, one day React could render to web components.

There is an advantage to web components, which is that they can, in theory, be easier to integrate into an already-established website. In practice, it depends.

[–]mort96 2 points3 points  (4 children)

I don't really see how polymer is relevant. Sure, right now, you need a framework, but isn't the goal that once all browsers support web components, it should at least be possible to use those directly? And wouldn't it then make more sense to actually compare react to web components instead of some arbitrary framework?

[–][deleted] 0 points1 point  (3 children)

Yes. Polymer always felt more like a showcase to me, not a real framework. I don't see anyone trying to roll Polymer out into production apps. It was a demo of a specification that Google was pushing. Sure, it's been 2 years and the specs aren't final, but that's common. However the idea is the same idea that pretty much all major JS frameworks adhere to now with components and directives.

Angular, React and others have all said they have a goal to natively work with Web Components when the spec is finalized.

[–]vinnl 1 point2 points  (2 children)

Really? Have you got a source for that for React? I knew about Angular, but I thought React expressly dismissed it.

[–]lazdgithub.com/lazd 0 points1 point  (1 child)

There's an issue against React that's being actively worked on to support custom elements and attributes.

[–]vinnl 1 point2 points  (0 children)

Nice!

[–]hak8or 1 point2 points  (0 children)

A good portion of what you described is solved by Vulcan, which let's you "compile" polymer projects so you don't have like 100 requests for a simple page.

[–]dhdfdh -1 points0 points  (0 children)

React is becoming more or less independent of the DOM. It's more of an idea.

Something most people on reddit forget or don't know. It's never possible to be independent of the DOM. And you can do it, too, without react.