47

What are the main benefits of Facebook's React over the upcoming Web Components spec and vice versa (or perhaps a more apples-to-apples comparison would be to Google's Polymer library)?

According to this JSConf EU talk and the React homepage, the main benefits of React are:

  • Decoupling and increased cohesion using a component model
  • Abstraction, Composition and Expressivity
  • Virtual DOM & Synthetic events (which basically means they completely re-implemented the DOM and its event system)
    • Enables modern HTML5 event stuff on IE 8
    • Server-side rendering
    • Testability
    • Bindings to SVG, VML, and <canvas>

Almost everything mentioned is being integrated into browsers natively through Web Components except this virtual DOM concept (obviously). I can see how the virtual DOM and synthetic events can be beneficial today to support old browsers, but isn't throwing away a huge chunk of native browser code kind of like shooting yourself in the foot in the long term? As far as modern browsers are concerned, isn't that a lot of unnecessary overhead/reinventing of the wheel?

Here are some things I think React is missing that Web Components will care of. Correct me if I'm wrong.

  • Native browser support (read "guaranteed to be faster")
  • Write JavaScript in vanilla JavaScript, write CSS in CSS, write HTML in HTML.
  • Style encapsulation using Shadow DOM
    • React instead has this, which requires writing CSS in JavaScript. Not pretty.
  • Two-way binding
CletusW
  • 3,890
  • 1
  • 27
  • 42
  • 4
    This is a great question for programmers.stackexchange.com – Seth Ladd Jan 24 '14 at 21:05
  • 2
    Done! http://programmers.stackexchange.com/questions/225400/pros-and-cons-of-facebooks-react-vs-web-components-polymer – CletusW Jan 25 '14 at 00:47
  • 3
    Also, if someone with enough reputation on programmers.stackexchange.com could add some new tags for me (reactjs, web-component), that'd be great. – CletusW Jan 25 '14 at 00:48
  • I posted my answer [here](http://programmers.stackexchange.com/questions/225400/pros-and-cons-of-facebooks-react-vs-web-components-polymer/237762#237762) – rsp May 03 '14 at 02:15
  • 2
    why is "write CSS in CSS" a good thing... – Erik Kaplun May 05 '15 at 10:30

0 Answers0