4 ms·
> JSX is just JavaScript No, it's not. It's the bastard child of XML and JavaScript. I agree that your examples are about the best you can do with JSX. But
by couchand 9y ago
> JSX is just JavaScript
No, it's not. It's the bastard child of XML and JavaScript. I agree that your examples are about the best you can do with JSX. But actually just JavaScript is much easier:
render() {
return Bar(someCondition && Foo())
}
or
render() {
return Bar(someCondition ? Foo() : null)
}
That's not quite hyperscript but it's not far from it.
- AnkhMorporkian 9y agoI believe the OP was saying that JSX is transformed into pure javascript, not that it's literally javascript.
- exogen 9y agoDigs at JSX aside, I think you may have lost track of what this thread was about: complicated nested conditionals. These are a pain to do in a single JS expression, JSX or hyperscript or otherwise – even in your example. In JSX your simple example would look just as nice: <Bar>{someCondition && <Foo/>}</Bar>