News for hackers. Stuff that matters.
Re:React, JSX and ES6: The Weird Parts by meesles on Tuesday August 25, 2015 @09:48AM (#10116407)
I disagree with this point: Using conditionals in your view components.

Putting if statements into your view is not the React way. You should be rendering something like {productList}, and that productList() function should be the one handling any outstanding logic. Even better, Your React should be generic enough to accept data you filter and edit in your controllers.

Re:React, JSX and ES6: The Weird Parts by funkiee on Tuesday August 25, 2015 @10:53AM (#10116919)
More on that point. The reason you cannot use if/else within JSX is because the statement needs to evaluate to an expression. If you really need to use if/else logic embedded, a ternary operator would work just fine.

return ( <nav> <Home /> { loggedIn ? <LogoutButton /> : <LoginButton /> } </nav> );

Re:React, JSX and ES6: The Weird Parts by muzmath on Tuesday August 25, 2015 @03:12PM (#10118828)
I was hoping someone would mention this. Between this and an extended rant about `dangerouslySetHtml`, I would say this author was really scraping hard to find negative things about React. Poor quality article.
Re:React, JSX and ES6: The Weird Parts by meesles on Wednesday August 26, 2015 @10:45AM (#10123221)
I use these a bit and think they're great! If your logic is more complicated than one line it doesn't belong in there.
Re:React, JSX and ES6: The Weird Parts by glifchits on Tuesday August 25, 2015 @10:57AM (#10116944)
Fully agree. To call lack of conditionals a "limitation of JSX" is also very misleading. JSX is a pretty simple wrapper for Javascript function calls. The fact that you can't put an if statement in your JSX is due to the fact that you can't supply an if statement as an argument to a Javascript function.
Re:React, JSX and ES6: The Weird Parts by bpicolo on Tuesday August 25, 2015 @11:50AM (#10117308)
I consider it a big positive that you can't.
Re:React, JSX and ES6: The Weird Parts by mxxx on Thursday August 27, 2015 @07:29PM (#10132795)
If you really need to, I don't mind this pattern...

{conditional && (

  <div>throw whatever you want</div>
  <div>in here.</span>

)}
Re:React, JSX and ES6: The Weird Parts by shuzchen on Tuesday September 01, 2015 @02:55PM (#10154829)
Of course, this doesn't actually work, because you have two root elements in that expression. You have to wrap them in an enclosing tag or inject them another way.