3 ms·
React is a different way of building user interfaces. Instead of finding the right UI element to update, you write functions that generate a description of the
by natrius 11y ago
React is a different way of building user interfaces. Instead of finding the right UI element to update, you write functions that generate a description of the entire UI from the state, then the library calculates the differences to update the changed elements.
As a result, old advice about separating code from templates does not apply. Combining code and templates is the right thing to do in React, and JSX is far more pleasant to read and write than the native function call syntax, which is still available if you really don't like JSX.
If you haven't tried it, you should.
- leeoniya 11y agoit has nothing to do with jsx. all vdom libraries do this. redraw-the-world is done much faster than React by numerous libraries, including mine (see other comment in this thread). Inferno is a lib that will probably replace React while maintaining jsx compatibility, check it out btw. jsx is just more natural for designers but i agree with the gp that the benefits can be obtained with plain declarative js and avoid all the tooling required for jsx.
- natrius 11y ago> all vdom libraries do this. Most developers have never used a virtual-dom library, especially those that find JSX offensive. Your sales pitch for your library is coming off pretty aggressive, and it's a bit off topic. No one is talking about render speed.
- leeoniya 11y agowell, if the topic is how great jsx is, it's on topic for me cause the lib was written specifically to scratch that itch :)
- davexunit 11y agoYou are assuming a lot. I know how to write purely functional template code using the virtual DOM in JavaScript, or something like SXML in Scheme. You can do this without using a terrible mashup of XML and JavaScript. > JSX is far more pleasant to read and write than the native function call syntax No, it isn't. XML is both hard to read and write. It's for machines, not humans. Besides that, mixing two languages with two very different syntactic structures together is a recipe for disaster. And besides that, you now need an additional compilation step because it's not plain JavaScript. What works much better is something like Mithril's templating API, which is concise and pure JavaScript.
- natrius 11y agoOkay. Most people prefer reading and writing JSX, and haven't found it to be "insane" or a "disaster." I'm glad you found a library you prefer!
- _pmf_ 11y ago> As a result, old advice about separating code from templates does not apply. Combining code and templates is the right thing to do in React That's a very accurate observation and it's a very strong argument against React.
- mateuszf 11y agoIt's not against. React code is a part of view layer. Therefore it is kind of template code with amazing full programming language power instead of standard limited approaches.