6 ms·
Depends what you call idiomatic. I dont think JSX is really a JavaScript idiom, more like a HTML idiom applied to JavaScript which happen to be often used toget
by Shywim 9y ago
Depends what you call idiomatic. I dont think JSX is really a JavaScript idiom, more like a HTML idiom applied to JavaScript which happen to be often used together.*
At the end of the day, I think that calling something idiomatic is subjective and so, varies from people to people.
*: to be clear, my point is many people use JSX with React because it feels idiomatic (I manipulate HTML/DOM, so why not just write with HTML-like syntax?) but it is not idiomatic to JavaScript and I don't think the other React APIs are that nice to use. If I didn't use JSX with React, I'd tend to use other framework because, in my opinion, they make more sense.
- l1ambda 9y agoJSX is optional.
- oceanswave 9y agoAnd vue optionally supports Jsx, so original comment or using it as a reason why ‘react sucks’ is being super pandentic. It’s ok to have multiple frameworks!
- Touche 9y agoOptional features contribute to a tool's complexity, especially when every single example assumes you are using said optional feature.
- bpicolo 9y agoIt's optional, and also not optional. Nobody is using React without JSX in practice, because it's ugly and verbose.
- l1ambda 9y agoNot true, without JSX, React is basically Mithril, if you alias React.createElement to a short function name.
- bpicolo 9y agoYeah, and I'm arguing that it's pretty ugly to write nested html that way. Hater-or-lover of JSX, it is definitely an intuitive way to think about HTML in the context of JS. I prefer the vue model that's a bit closer to the metal, though, if only because of quirks like className
- l1ambda 9y agoThink I see what you are getting at--in practice most folks using React are going to use JSX and build tools, and if you alias the function it's kind of non-standard. Mithril has "class" instead of "className"; that irks me too.
- cnp 9y agoAnd <Foo bar={'hi!'} /> is the same as Foo({ bar: 'hi!' })