|
|
|
|
|
by Touche
3490 days ago
|
|
JSX is not JavaScript. If its not in a spec that is ever going to be implemented by a JS runtime, like a browser or Node.js, then it's not JavaScript. It's a superset of JavaScript. If you admit that JSX is a superset of JS then the downsides become readily apparent. Many will still choose JSX and there's nothing wrong with that, but the argument isn't "why would I use X when Y is better". |
|
> <element someProp={prop} /> = React.createElement('elment', {someProp: prop}, null)
Its such a simple transformation and adheres to javascript standard behavior. JSX doesn't add anything new, it just adds a way to do something old.
Its a shortcut to 1 transformation and thats it. You can unpack it in your head.
So while I agree with you that it isn't "standard javascript", if you look past the visual differences, there is no difference between JSX and javascript.
This is in stark contrast to the Vue.js (and other) template systems which, while they compile to javascript, the amount of transformations makes it impossible to extend the template system easily without touching the internals of the template engine.
JSX is just syntax, other template systems are entire secondary languages.