4 ms·
Why not JSX? To me, JSX is part of React. If someone starting with React sees all that React.create element, they will run away.
by manojlds 11y ago
Why not JSX? To me, JSX is part of React. If someone starting with React sees all that React.create element, they will run away.
- DatBear 11y agoAbsolutely this. I just started learning React a few days ago, and I absolutely would not have given it a chance with all those React.createElements. That looks like hell.
- benatkin 11y agoSome people don't like JSX. This is fine. But to imply that it's not part of React by calling the non-JSX variant "raw React" is misleading.
- antris 11y agoIt's not misleading at all. I've created several React apps without JSX. I just didn't feel I had a need for it, and React without JSX worked really well. People make these exaggerated comparisons of raw React code vs. JSX where they show unrefactored code with React.createElement spammed all over the place. With functional programming principles you can cut that syntax down to almost the expression power of JSX.
- bgilroy26 11y agoI don't think this is intended to replace 101-level tutorials. This is to help break down what's going on behind the scenes after you've been through todolist etc. In the article Mr. Nelson says the intended audience are people who have "spent a couple hours investigating" already.
- jamesknelson 11y agoAuthor here. My target audience here was really people who've already decided they're going to use React, and are keen on understanding what is going on under the hood. And while I do love JSX (and use it in my own projects), my feeling is that to really grok React, writing something without JSX is invaluable.
- SiVal 11y agoI'm part of that target audience, and you scored a bullseye with me. I always prefer to learn a new technology this way, by building very simple things from scratch and making minor modifications this way and that until I know what all the low-level parts do. Then, you can add some conveniences to the mix explaining what they do in terms of the underlying technology I just learned (and I can tell which parts are the base technology and which belong to this add-on), until I feel I could recreate these conveniences or build my own alternatives, if I chose to. That way, I can decide for myself how to use the technology, break away from the typical stack of add-ons at any point I choose and take it from there in a direction that better suits my needs, dig in and figure out what's going on if I have a problem, and so on, rather than being helplessly dependent on a magical black box. Thank you for starting off by teaching low-level React without any JSX, Flux, Redux, or whatever. I wish more tutorials did that.
- dclowd9901 11y agoWhen I started learning iOS dev, every tutorial pointed me at the interface builder. It drove me nuts because I'm doing this magic and things are happening but when something fails I have no clue what to do, and guess what: things failed a lot and for weird reasons when you used IB and didn't know how it worked under the hood. Granted JSX is far less bloated than IB, but its important to understand <Component /> bootstraps a react class component and <div> just renders a div.
- antris 11y ago> If someone starting with React sees all that React.create element, they will run away. That's a possible reaction. Other developers would refactor instead of running away, though. Not using JSX doesn't mean typing React.createElement all over the place. var e = React.createElement And you already have much neater code. You can even go further and create functions for p, h1, input etc. and you're almost down to the expression power of JSX. And as a bonus, you don't have to spend time learning the JSX compiler and syntax.
- adamwong246 11y agoNot for me. I hate JSX, mainly because I like coffeescript and jade. I write all my code, view and otherwise, in coffee.