4 ms·
Same here. In my opinion JSX is one of the best thing happened in the front-end world. Let's not forget how horrible Angular templating was: <ul ng-if="::
by ggregoire 10y ago
Same here. In my opinion JSX is one of the best thing happened in the front-end world.
Let's not forget how horrible Angular templating was:
<ul ng-if="::vm.items.length">
<li ng-class="::{ 'active': item.active }" ng-repeat="item in ::vm.items | orderBy: 'id' as ordered track by item.id" ng-click="item.active = !item.active">
{{::item.name}}
</li>
</ul>
<select ng-options="item.subItem as item.label for item in ::vm.items2 track by item.id" ng-model="selected"></select>
<div ng-include="selected.template.url" />
- syaz1 10y agoWow, that looks really messy for what is essentially printing items in collection...
- nkozyra 10y agoI believe that will always be the case when you have to embed logic into a relatively rigid markup language. Syntactically, JSX feels more native, but both are addressing the same problem.
- vladimir-y 10y agoJSX is just a way to render data, so think like it's a templater, you can integrate it with any tool. React istelf is also just an advanced templater actually, it has no built-in data reactivity despite the name. In my opinion React is not needed in general and JSX is a back to the old fashion PHP coding (Facebook returns to its roots).
- iotscale 10y agoReact is not a templater, it's a differ. The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code. Edit: After reading my comment again, I feel I must mention; even that similarity is not coming from React directly. It's JSX. Although they go like fish & chips together (Not a great analogy but I guess I'm hungry).
- vladimir-y 10y ago> React is not a templater, it's a differ. It's a templater, read my message above - an advanced tempalter, which means it has some DOM rendering optimizations. > The only similarity between PHP and React is that you can have tags in ("around" in PHP's case) your code. Not just tags, but an entire "view" thing, a representation, so old fashion messy/sloppy/spaghetti-like PHP like code style.
- iotscale 10y agoYou give React a state, it diffs that and passes the outcome to the ReactDOM, which can render it on the DOM. At its core React doesn't know what a <div/> is. It just diffs objects and generates instructions to reach the next state (very generally speaking here). The stuff you pass to it is an object and can't be malformed like a string can. Main function of React is maybe loosely related with templating. For PHP (in its traditional form), everything around the code is just strings, which is also the case for most of the templating engines. You can't shout "spaghetti code" every time you see XML tags in code. Think Scala or VB.
- catshirt 10y agonothing about React is messy or sloppy. it is the exact opposite. the notion that your view logic and it's template must be completely decoupled is an antiquated and misguided best practice.
- FrancoDiaz 10y agoOh boy, what a mess. I have only heard the horror stories of Angular 1, but had never seen a disaster like that.