5 ms·
From my point of view, React brings two important ideas to web app development: 1. The virtual DOM. When I'm writing jQuery-based code, I have to write both a
by hathawsh 11y ago
From my point of view, React brings two important ideas to web app development:
1. The virtual DOM. When I'm writing jQuery-based code, I have to write both a component template and code that updates the DOM in response to input; when I'm writing code for a virtual DOM, the component template is sufficient to update the DOM and I don't have to write that extra code, so there are fewer chances for bugs to creep in.
2. HTML-like syntax embedded in Javascript (JSX). I didn't like this at first until I configured Sublime Text to highlight embedded HTML correctly. Embedded HTML has pros and cons, but I think it's a net positive.
React projects also typically include new tech like ES2015, webpack, hot code reloading, and Redux with its time-traveling debugger. You can build your own stack that uses a virtual DOM library, embedded HTML, ES2015, and so on, but it's helpful to start with a common stack that many people understand. That's why React is interesting.
- up_and_up 11y ago> I didn't like this at first until I configured Sublime Text to highlight embedded HTML correctly Can you share your sublime settings or syntax configuration you are using?
- mrcarrot 11y agoI'm not the parent, but I wrote this [1] a year ago, and I think at least the first section still works for getting JSX syntax highlighting working. [1]: http://petethompson.net/blog/js/2015/02/25/sublime-text-3-and-modern-js/ http://petethompson.net/blog/js/2015/02/25/sublime-text-3-an...
- hathawsh 11y agoI follow Dan Abramov's recommendations: https://medium.com/@dan_abramov/lint-like-it-s-2015-6987d44c5b48 https://medium.com/@dan_abramov/lint-like-it-s-2015-6987d44c...
- foxhedgehog 11y agoJust a note paraphrasing a Medium post that I encountered that extends point 2: it's a lot more robust to work with a framework that essentially puts HTML into Javascript rather than many alternatives, which essentially do the reverse. Javascript is a lot more complex than HTML, and yet most of the alternative JS frameworks attempt to compress some version of its logic into templating.
- mattmanser 11y agoSo we should throw away decades of practical experience in all the other platforms that this is a bad idea because some blog post said so?
- foxhedgehog 11y agoSurely your decades of practical experience can instance an evidence-based response here.
- mattmanser 11y agoWhy the personal attack? It's not a 'new' complaint about React, it's been said plenty of times, go do your own research.
- foxhedgehog 11y agoObserving that your only point of evidence is your own unsubstantiated personal opinion is not the same thing as conducting a personal attack.
- yoz-y 11y agoWhat other platforms embed a subset of a language into the templating one? I've only seen this done in HTML. Even "back then" I opted to use pure PHP for templates rather that trying to use some comment magic based DSL that does little more than variable replacement and a for loop. The templates in Angular for example are a good example of what is wrong with stuffing code into templates rather than going the other way around.
- mattmanser 11y agoIf by virtual Dom you mean data binding, that's not a new concept, it's just not been client-side because JavaScript was too slow until recently. Also data-binding brings its own myriad of problems that older programmers will know about from the days of desktop programming. And 2 just sounds like a violation of the rule we've all learnt not to mix presentation and code. So they're not reasons why React is interesting.
- tehbeard 11y agoPerhaps you could elaborate on the myriad of problems with data-binding the prior generation has encountered, and how they are fixed or exacerbated by React's solution? And with number 2, this is subjective, should a template be responsible for rendering it's children (necessitating the need for for loops)? Should it handle filtering in the case of tabulated data, in a way that is consistent and re-usable, or should this be another layer sat between model/controller and the view?