React, JSX and ES6: The Weird Parts
ponyfoo.com
ponyfoo.com
well, you just should get the idea that these curly braces are not for interpolation. It's just convenient way to define a component tree. If you want interpolation, you should use <span>{`foo ${'bar'} ${'baz'}`}</span> syntax.
This doesn't work:
<h1 className='{a} {b}'>...</h1>
So I did this: <h1 className={`${a} ${b}`}>...</h1>
And then simply used this style everywhere, because it worked for text-nodes and attributes.So making each updatable component an actual (non-text) DOM Node is an unfortunate requirement.
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.
return ( <nav> <Home /> { loggedIn ? <LogoutButton /> : <LoginButton /> } </nav> );
{conditional && (
<div>throw whatever you want</div>
<div>in here.</span>
)} For some reason, React’s JSX make this unnecessarily complicated by not being able to use if statements inside code blocks.
Using if inside an expression isn't javascript! It would be some shitty templating language, and I'm grateful it didn't turn out that way.I'd love to have a JSX like syntax in LiveScript, because it has if-expressions.
Well put, since the issue doesn't appear when using CoffeeScript.
Basically, on every keypress you need to capture the change and rerender. It may be fast, it may be what the browser is doing under the hood, but it feels VERY weird.
It also means that things like divs with contenteditable on them are basically unworkable in the current version. :(