4 ms·
React was advertised from the start as the V in MV-whatever, so that seems like an overly restrictive definition of "idiomatic". > At which point, JSX is basic
by DougBTX 8y ago
React was advertised from the start as the V in MV-whatever, so that seems like an overly restrictive definition of "idiomatic".
> At which point, JSX is basically just another fancy HTML templating library.
JSX is optional syntax sugar; my team uses React and Redux heavily, but we've opted not to use it.
HTML templating is great actually, all the rendering is data -> UI.
If you go back to the early Rethinking Best Practices presentation[0], it boils down to asking why client side development isn't like like HTML templating. The answer is that updating the entire page DOM on every change is unworkable, there needs to be support for partial updates. That's what React offers, a return to the data -> UI paradigm, without having to write a secondary code path for partial updates.
[0] https://www.youtube.com/watch?v=x7cQ3mrcKaY https://www.youtube.com/watch?v=x7cQ3mrcKaY
- acemarke 8y agoOut of curiosity, what are you using instead of JSX? Plain `React.createElement()` calls, `createElement` aliased to a shorter variable like `e`, or something like the `react-hyperscript-helpers` library?
- spiritcat 8y agoit's funny how originally jsx is what kept me away from react, and now it's what keeps me from leaving.
- interlocutor 8y agoYou can actually leave react and still keep JSX. This tiny library lets you use JSX as a templating mechanism: https://github.com/wisercoder/uibuilder https://github.com/wisercoder/uibuilder
- kibibu 8y agoIt's funny how everybody hated E4X when Adobe and Mozilla were doing it, and love JSX now.
- spiritcat 8y agoI didn't even know this existed.
- DougBTX 8y agoWe’re still using https://www.npmjs.com/package/react-dom-factories https://www.npmjs.com/package/react-dom-factories for plain DOM elements, so code looks like dom.div({ props }, ...) For our own components, we export the output of React.createFactory https://reactjs.org/docs/react-api.html#createfactory https://reactjs.org/docs/react-api.html#createfactory rather that the component itself, so rendering code looks like: MyComponent({ props }, ...) I realise that both of those are marked legacy, with a nudge towards using JSX instead, but they are pretty thin wrappers around createElement so it seems like a small dependency.