2 ms·
You are saying this... var rootElement = React.createElement('div', {}, React.createElement('h1', {}, "Contacts"), React.createEleme
by pknopf 9y ago
You are saying this...
var rootElement =
React.createElement('div', {},
React.createElement('h1', {}, "Contacts"),
React.createElement('ul', {},
React.createElement('li', {},
React.createElement('h2', {}, "James Nelson"),
React.createElement('a', {href: 'mailto:james@jamesknelson.com'}, 'james@jamesknelson.com')
),
React.createElement('li', {},
React.createElement('h2', {}, "Joe Citizen"),
React.createElement('a', {href: 'mailto:joe@example.com'}, 'joe@example.com')
)
)
)
...is just as readable as this?
var rootElement =
<Div>
<H2>Contacts</H2>
<Ul>
<Li>
<H2>James Nelson</H2>
<A href="mailto:james@james.com">
james@james.com
</A>
</Li>
</Ul>
</Di>
The whole point of JSX is to make working with React more like html, because it is easier and more readable.
> How's that an argument at all?
Huh? You mean, the argument that you shouldn't be sending un-compiled content to the client? I don't know why I'd have to argue for this, but render speed is one of the big reasons. Also download size. If you don't recompile, you have to include babel as well, on the client.