7 ms·
If you know only JS, JSX is much easier to pick up than some proprietary templating language. How do I do an if, a loop, a map, ... any code at all? In JSX, the
by christophilus 9y ago
If you know only JS, JSX is much easier to pick up than some proprietary templating language. How do I do an if, a loop, a map, ... any code at all? In JSX, the answer is squiggly-brackets and regular old JS code. In Angular's templating system and Vue's, you've got to relearn all of these and more.
- aloisdg 9y agoYou can use JSX without trouble with Vue
- sasmithjr 9y agoHere's a link for anyone wanting to read more about it: https://vuejs.org/v2/guide/render-function.html#JSX https://vuejs.org/v2/guide/render-function.html#JSX
- rocky1138 9y ago> proprietary templating language Isn't that exactly what JSX is?
- jsd1982 9y agoNo. JSX is a small domain-specific language for expressing a hierarchy of virtual DOM nodes. Angular is a template language in that it eschews JavaScript compatibility in favor of its own directives that try to emulate basic iteration and conditional expression evaluation.
- davidjnelson 9y agoI wish you could write non string based jsx in angular. Or at least make aot fast enough for the regular webpack watch / recompile workflow.
- chrisco255 9y agoNo it's a standard. You can use JSX with Vue 2.0 now, as well as Preact and others.
- ageofwant 9y agoJSX has nothing to do with 'templates', it's an alternative javascript notation. When you write JSX code you write javascript code, using JSX syntax.
- gruez 9y agoI think he meant that in vue.js/angular you have to learn a bunch of proprietary tags for each construct (if, foreach, etc.), whereas in JSX all you need is plain old javascript.
- deleted 9y ago[deleted]
- vec 9y agoThis is probably true, but it's a really poor rationale for choosing a templating* solution. Sure, JSX is slightly easier to pick up than a pure templating solution would be, but that doesn't mean learning modern templating tools is hard. Making already easy things easier isn't much of a win in my book. On the other hand, JSX is extremely difficult to read. I can glance at a relatively complex handlebars template I wrote two years ago and instantly understand what it renders. To do the same with a similar JSX component requires spending ten minutes to trace the control flow, understand all the helpers, and mentally re-inline all the loops and conditionals. It's conceptually simple, which is attractive, but in practice that seems to lead to noisy, nonlinear render functions that have little to no structural similarity to their final rendered DOM. It's also worth noting that JSX is easy to pick up for javascript developers. It's next to impossible for the kind of design-focused frontend people who know HTML and CSS inside and out but only ever needed enough JS to write the occasional jQuery selector. If you're certain your project will never have any styling input from people who aren't first and foremost programmers then JSX might be a great fit, but the rest of us actually have to work with our teams. * Yes, I know, JSX is technically not a template.
- always_good 9y ago> It's also worth noting that JSX is easy to pick up for javascript developers. It's next to impossible for the kind of design-focused frontend people who know HTML and CSS This seems more like a meme than reality. Design is hard. Someone that was able to credentialize in CSS of all things can learn some JS/JSX. Give them some professional courtesy and credit. Saying that it's "next to impossible" seems kinda toot-my-own-horn dismissive.