My main gripes are no TypeScript support and going to mustache-like templates after working with JSX/TSX is a step back for me.
Also losing React Native, which is non-issue if you're just developing a web app.
Also losing React Native, which is non-issue if you're just developing a web app.
<div>
{if (cond) {
<Comp1 />
} else {
<Comp2 />
}}
</div>
Or even: <div>
{switch (expr) {
| A => <CompA />
| B => <CompB />
| _ => <CompC />
}}
</div>It's the benefit of having a full language instead of a template DSL for rendering. Declarative syntax is easy inside of an imperative flow, doing the opposite tends to lead to problems though.
A redundant extra component is bad for performance.
function FileList() {
if (!files.length) {
return <EmptyMessage/>;
}
return <List items={files} />;
}
function FileList() {
return files.length
? <List items={files}/>
: <EmptyMessage/>;
}
What feels unnatural is the syntax that these templates pull out of thin air to do things the language can already do. Why should I need to learn another syntax just for templates?/me goes back to happily "server side rendering" HTML with PHP
I think it's a matter of personal taste.
<div>
{items.length === 0 &&
<p>No items.</p>
}
{items.length === 1 &&
<p>Warning: You only have 1 item, at least 2 is required</p>
}
{items.map(...)}
</div>
`false` is not rendered by react, so this code is perfectly fine.