2 ms·
JSX appeared before template strings where even an idea (I think :) ). The thing though, JSX doesn't return DOM elements. It's a very thin DSL on top of React.
by dmitriid 10y ago
JSX appeared before template strings where even an idea (I think :) ).
The thing though, JSX doesn't return DOM elements. It's a very thin DSL on top of React.createElement calls. Since it's Javascript all the way down, you get a number of benefits:
- you are not constrained by limitations such as "attributes can only be strings" or "children can only be DOM Elements". It's all Javascript expressions
- React knows the return value. It can do efficient diff'ing against its internal DOM representations and only update the actual DOM as needed (same goes for other virtual dom implementations such as snabbdom, virtual-dom etc.)