Stop using React for everything
medium.com
medium.com
I can't find one reason why ES6 and component-like architecture wouldn't be chosen "often" for projects? React is the first javascript (frontend) framework I use that allows to easily break down architecture and keep a complex (or simple) application clean and well structured. It feels like writing server-side code.
"For static sites, Jade is a fantastic templating engine." Cool. But why compare how to use a javascript, dynamic framework for static sites? That's just a bad argument.
"For data-bound REST apps, I choose Angular. " Good for you but... why Angular over React? Those are 2 frameworks that are supposed to do the same thing (build dynamic front end applications) with 2 different sets of mind. But... I build REST apps with React. I even build Forms with React. And they are not even dynamic. What's wrong with it? It makes my code, form validation, form submit way cleaner, easier and reusable! What should I do instead? Use vanilla js? jQuery? Why? Because it's enough? It's enough, but trust me, I've recently (no later than last week!) refactored some of our forms with React, and it-is-so-much better.
I totally agree with the author's point of "do not use X for the hype and everything, but use X for the good reasons" but the argument given is plain bad and examples are wrong.
There are some cases though where the component model feels strained — consider components that act as a pass-through for debouncing data, components that implement routing as a tree of routes and handlers, or components that perform data-fetching. Perhaps it's that the community hasn't found the right APIs for these higher-order components, but it's hard to argue against using React for a stateless tree of UI components.
Also, I don't mean to be snarky, but I suggest the writer uses fewer ALL CAPS, fewer exclamation marks and tones down the provocations to be more convincing.
There are certain categories of web applications and pages which do not benefit at all from React (or other semi-related technologies like Angular), and it's folly to pretend that they do.
If you want to go the "it's a toolbox" route...showing up to a carpentry job with a plumbing toolbox isn't useful.
That's like saying there are certain programs in which functions do not provide any benefit at all. It's folly to pretend that they do.
Because they were part of its creation and are invested in it.
> Or why companies like Sony, Reddit, and Pinterest use Backbone.
Pinterest just switched to React.
> Or why companies like Netflix, Yahoo, and LinkedIn use Ember.
Netflix just switched to React.
> There are smart people out there not choosing React. Ask yourself, why not?
Not for long.
It's gonna be a long time.
More like "until the next big framework becomes popular."
If you are a frontend javascript consultant, than by all means, learn them all.
React brings sanity to the web UI world. It brings reusable components! It brings composition. It brings modularity.
... and it's written by adults who know CS. Your UI is a pure function of your state. Who knew?
Why would I use anything else? Really? Do I want state-management spaghetti and over-engineering?
The only way I'd give up React for dynamic sites/pages is if the web standards groups made Web Components into something that was actually as good as React and baked this into the stack. But somehow I doubt that's going to happen. Web Components might turn into something good to compose UI but you'll probably still need React to add dynamic behavior to it.
The main benefit of virtual DOM afaict is that it makes rendering on the server trivial without needing to jump through all the hoops that, e.g. Angular has to. Contrary to the post, this makes it ideal for such sites.
"If you have a highly dynamic application that needs to rerender frequently, and you want to avoid the heavy weight of template diffing, [...] ReactJS’s virtual DOM will be super effective. However, if you’re site doesn’t have those needs, CHOOSE SOMETHING ELSE!"
Well choose a DOM representation implementation in this case. That's not what React is all about. And may I add that, "Virtual DOM" or however you want to call it, will never be as fast as manual DOM manipulation done right. It's just a well documented convenience magic abstraction.
We no longer have vast incompatibilities among browsers, so we no longer use JQuery. At the same time, threads pop up everywhere titled "how do I do [this] in [Angular, React, etc.], just like it has happened with JQuery in the past. And I won't even mention framework specific "plugins" ..
The underlying problem is, the majority of people involved with JavaScript for the web platform, are afraid and/or lazy learning it. And no framework can cure this, but at the same time frameworks help us hide the pile of ignorance we have under the framework carpet.
I'm not bashing anyone, frameworks can inspire and help organize vast amount of work. But at the same time they are hard dependencies, hailed by well known developers. Sooner or later there will be new ones [that got it right this time] and the cycle of hype-wow-sucks will continue. Well they are all built with JS, so how about you take your time to learn the language and philosophize a bit on programming, state management, application structure and the capabilities (as well as the bottlenecks) of the web platform? Then you may choose any framework you like at any time and you won't be shooting yourself in the foot because you'll be using it as a tool, and not the panacea for all your troubles.
What if I really like the programming model behind React? My UIs are so easy to reason about now, and that's why I like it so much.
I can't use React at work, but I don't want to stagnate either. That's why I'll always be using the most ridiculous trendy technologies for side projects.
I do think that's how most of frontend developers live nowadays.
At the same time, I worked in a couple places that used better, but less fancy languages/frameworks. I won't name them to not attract a horde of "but Erlang/Racket/Ember is the best thing". There was a repeating pattern of having a hard time with both recruitment and with actual development. People didn't know our tech, or they did but not as well as they claimed they did. Then there was all the trouble with finding libraries, examples and general help of any kind with less popular tech. I suppose the cost of using a wrong but popular tool (be it React or anything else) may actually not overweight the cost of using the right tool which in general is harder to utilize.
"your" not "you're". Sorry I had to do it.
If you need something done and done fast with decent code separation, feel free to pick up React. If you need to optimize for performance (because many of us need to at some point) or you have a good understanding / way to architect your code to keep up a good separation of DOM and business logic then use almost anything else.
Hell, you don't even need to use a framework for the web. My last project I didn't use any and it was perfectly fine. Frameworks are great to get you going faster and doing the hard parts for you but you don't always need that.
In my opinion anyway.
" React, Angular, Ember, Backbone, Vue, Knockout, Mithril, Jade, Django, Rails, etc. "
Oh yeah I never built _____ cause I was busy learning a, b, c, x, y, and z frameworks and by the time you have those down there are three new ones. When most likely what you are doing any of the big ones will be fine so just pick the one you want to learn, or know already or whatever works best for you.
The reason for a one-size-fits-all choice is that I really don't want to have to learn the ins and outs of 3-4 different frameworks and libraries. Even if React doesn't exactly fit the model of a certain application, it makes sense to shoe-horn it in to avoid a fragmented technology stack. I only have so much space in my brain.
Yes, but beef I have with the cool kids I've worked with are they throw out the entire app: MVC, Server, etc. so they can use this magical V - then completely rewrite and wing the rest of the app "Oh it's, um, 'Flux Architecture'"
I honestly don't know if there's any point to trying to learn it over getting better at Angular when we have so much invested in Angular, and there's a new coolest JS framework every other week anyways.
"You might not need React"TM , or "Occupy React"TM soon next to your dev shop /s
PS This week's framework is actually Falcor
The CEO of the Meteor Dev group gave the following presentation recently:
https://www.youtube.com/watch?v=8G2SMVIUNNk
He indirectly touches on some of those probably 25 minutes into the talk.