|
|
|
|
|
by aaronyo
4144 days ago
|
|
Big fan of React. For others using it, why use JSX instead of just doing everything in js? In other words, why is HTML like this: <Group style={styles.group}>
<Image style={styles.image} src='http://...' />
<Text style={styles.text}>
Lorem ipsum...
</Text>
</Group>
Preferable to something like this (which can easily be done with some helper methods wrapping the verbose React DOM methods): $group({styles: style.group},
$image({styles: image, src: 'http://...'}),
$text({styles: style.text},
'Lorem ipsum...'));
No pre processing step required, and of course it's natural to imbed js in, er..., js.What am I missing? Why keep the HTML part in all this? |
|
The second approach is what I was doing in various flavours for years prior to JSX. I ended up having to adopt comma-first to stay sane in larger/deeper templates, ( e.g. https://gist.github.com/insin/8e72bed793772d82ca8d ). The first thing I did when I saw JSX was start to write a React.DOM emitting version of my then-usual JSON-ML type stuff, but then I tried it and... never going back.