Description
I see a lot of questions, blog posts and discussions around React
and WebComponents
, but none of them are actually an official statement from Facebook that could clarify whether or not React
will going to implement WebComponents
W3C specs in the future.
There are also quite a few GitHub Issues around this subject, like "Enable rendering into shadow roots" #1167, "Allow rendering into a document fragment" #840, "Track upcoming DOM technology upgrades" #2836, "Proof of concept: Shadow DOM support" #1877, "Support for custom DOM elements & attributes" #2746, "Templates?" #2286, "Add naive custom element support" #1249, "Add support in the future for custom elements" #1214 etc.
Nevertheless there are some open-source projects that allows React
to be WebComponents
-aware, like https://github.com/Wildhoney/Maple.js, https://github.com/wix/react-templates or https://github.com/PixelsCommander/ReactiveElements
As for WebComponents
, it seems that the reconciliation between HTML Imports
and ES6 Modules
is inevitable, thus the HTML Imports
part of the spec might need to change in order to be widely accepted among the open-source community and browser vendors https://bugzilla.mozilla.org/show_bug.cgi?id=877072 Until then, wrapping components and importing them as ES6 Modules
is as good as including them in HTML pages and importing them with <link rel="import" />
The Custom Elements
are more or less about defining new markup that you can interact in the same way as with native HTML elements, allowing you to extend existing native HTML elements and giving you some lifecycle methods. This is already possible with React
and JSX
, even though JSX
's XHTML-like syntax transpiles to JavaScript which ultimately becomes HTML through the Virtual DOM
.
Shadow DOM
is hard and in some cases even impossible to be polyfilled. This is the reason why Polymer
is using Shady DOM
https://www.polymer-project.org/1.0/articles/shadydom.html With the current browser support http://caniuse.com/#feat=shadowdom, adopting BEM
conventions or even inline styles backed by JavaScript objects, which is what React
is doing, remains a viable alternative but still is different from Shadow DOM
.
Templates
are really pointless without data binding. Two-way data binding is slow because the Object.observe
polyfill (https://github.com/Polymer/observe-js) is slow. Also, two-way data binding is about code complexity and the fact that the more dependencies you have between between components, the bigger the complexity grows, as opposed to unidirectional data flow. React
's one-way data flow with immutable data structures has the potential to scale and be highly performant, especially if we think about large-scale applications and complex interactions between thousands of entities.
Even though the open-source community is looking both at React
and WebComponents
, in the end the developer experience is what matters most and drives adoption. No doubt standards are having their own place in this.
Therefore, my question is: what is React
's strategy for WebComponents
?
@sebmarkbage any thoughts?