When comparing JSX vs Web Components, the Slant community recommends Web Components for most people. In the question“What are the best solutions to "The JavaScript Problem"?” Web Components is ranked 29th while JSX is ranked 36th. The most important reason people chose Web Components is:
Very extendable as a single-import base layer for visual controls and probably also something like a react-redux Provider.
Specs
Ranked in these QuestionsQuestion Ranking
Pros
Pro Easy debugging with source maps
Pro Compiler optimization
For better performance.
Pro Catches bugs at compile-time because of its static type system
Pro Great for small—likely published—reusable libraries
Very extendable as a single-import base layer for visual controls and probably also something like a react-redux Provider.
Pro Works with any framework
Less recreation of the wheel and fewer wrappers.
Pro Fallback styling when not yet defined
Before a component's script defines the custom element—either as the page is loading or with JavaScript disabled—it can be temporarily styled via :not(:defined)
. This may prevent the need for SSR.
Pro Customizable templates via custom-recognized "slots"
slot="name"
and <slot name="name">
for customizing a component's HTML in specific areas of its shadow DOM. Also fallbacks when not defined.
Pro Stylable via custom-exposed "parts"
::part(name)
pseudo-element for styling elements within a component's shadow DOM.
Cons
Con Not well-suited for application wiring
Having to serialize/deserialize data between components is not convenient. You'll probably still need a [light/simple] framework. Some things are still quite nice, such as using the light DOM -- think <option>
with <select>
and <datalist>
.
Con SSR is potentially more difficult
…if you need more than CSS' :not(:defined)
, that is.
Check out this video to see how the creator of SkateJS handled it: https://www.youtube.com/watch?v=yT-EsESAmgA