JSX actually makes it more intuitive than that by having 0 reason for even needing to know when to use square brackets vs parenthses. It's simply curly braces and vanilla JS
this is a different statement than the sentence i responded to. square or round just indicates the direction of the binding. everything in angular is also vanilla js.
Re:Why we chose Vue.js over React
by dismantlethesun on Sunday December 11, 2016 @03:11PM
(#13152907)
I think what he means is that control statements don't exist in JSX. You have to write Javascript to do if-statements, looping, etc.
In React, there is no 'direction' of binding---its all one way, just like in vanilla Javascript, and in fact no binding on anything except low level elements' like divs. Components only receive props, which do not do anything at all until you write code that reads them and runs operations based on their values.
Thus components are simply function calls (it's what they compile to anyways), and JSX is just a syntax to write functional code.
i don't see how sprinkling if-statements in your html is cleaner than "magical attributes" but thats just me :)
It's not just you...this has been a pretty big toss-up with MVC style frameworks and view libs. Does business logic belong in the template? Or does it belong in some sort of view controller? Mustache.js insists that all decisions should be made before data is sent to the template. Most other libs allow the template to make decisions. I don't think there's a definitive answer. I kinda lean on making easy decisions in Handlebars templates... or, since our new app is in React, JSX.
if statement is one of the most basic concepts of programming and is opposite to magic
Re:Why we chose Vue.js over React
by bryanrasmussen on Sunday December 11, 2016 @04:07PM
(#13153220)
True, but some would argue that its use is a mark of lacking taste - https://medium.com/@bartobri/applying-the-linus-tarvolds-goo...
Re:Why we chose Vue.js over React
by jasoncchild on Sunday December 11, 2016 @03:30PM
(#13153020)
Wait, square brackets/parens indicates data binding direction in vanilla js? Huh?
Re:Why we chose Vue.js over React
by madeofpalk on Sunday December 11, 2016 @10:26PM
(#13155271)
It's still just a giant string blob which is interpreted by Angular at runtime. Just because it's in a seperate file doesn't change this.
JSX, on the other hand, is Javascript function calls. You're writing JS to describe the UI.
Re:Why we chose Vue.js over React
by abritinthebay on Sunday December 11, 2016 @08:06PM
(#13154691)
To be fair - the reason Angular 2 moved away from that is largely due to the influence of React
That's not a bad thing of course.
why would you do this in Angular? i thought the whole point was to use html templates in separate .html files. as for "magical" attributes, angular2 moved away from that and is using mostly native html attributes. i.e. [disabled]="x" [hidden]="x" (click)="myfunc()". Can't imagine it being more intuitive than this.