Why do you like or dislike React?

github logo ・1 min read

I have recently been learning about React, which, as you probably know is a JavaScript library. As far as I understand it, one of its greater strengths is that it works with a virtual DOM, which makes updating the real DOM faster. If you google it, you'll find lots of reasons to use it as well as reasons not to use it.

What is your take on React? Do you like it? Do you find it too big? Does it perform well? What are your reasons for using it or not using it?

twitter logo DISCUSS (14)
markdown guide
 

React is a tool that solves several very difficult problems when developing single-page web applications:

  • Avoiding unnecessary reflows/repaints when the DOM is manipulated, which could be considered a flaw in the way browsers work.
  • Event unbinding to avoid memory leaks, which could also be considered a flaw in the way browsers work.
  • A component definition and re-use model, which could be considered a must-have browser feature that we never actually got.
  • A counter-intuitive data management opinion that works surprisingly well in practice, which I would argue is it's the greatest strength, but also it's most confusing characteristic.

Having said that, if you are not developing a SPA, React is overkill. Furthermore, React is only a view layer and will become extremely difficult to work as the sophistication of the SPA increases if supporting layers are not built. One of the key points of frustration and confusion is that Redux is not a business or data layer, it is only a mechanism (a very simple mechanism at that) upon which these layers can be built.

In short, if I'm building a SPA I am happy to use React, as I think it is the current best-in-class View Layer. If I'm building a vanilla webpage, it is unnecessary.

 

Thanks for replying in such detail, that's very interesting.

 

I do like React's idea of using a virtual DOM, and it really simplifies frequent and complex state updates to the DOM. Being able to just drop in how the DOM should look like based on the current state, instead of having to manually figure out what needs to be updated when, and having the library only update the relevant parts of the DOM, makes developing web apps considerably easier.

I'm not a big fan of stateful components, though. I prefer working with hyperapp, which is similar to using React + Redux minus all the boilerplate. Either that, or I use a pure virtual DOM library* (like superfine or snabbdom) and roll my own state management.

* By pure virtual DOM library I mean a library that only does virtual DOM, not a library free of side effects. React nowadays has a lot of state and event management built in.

 

By the way, I've read the second article you linked and it is so wrong I don't even know where to start.

 

So far, I love it. It's relatively easy to pick up, its slick, loads fast and has been a great experience so far.

Plus, its in HIGH demand so I'm all about React right now

 

Other than being easy to pick up, what would you say is its greatest strength?

 

I don't know much about Vue or Angular thus instead of technical aspect, I find that the large community is an advantage.

That means you can learn and get supports from other developers fairly quickly.

A larger doesn't necessarily translate to such a behavior but I found the React community very vibrant and supportive of each other.

That's true. Supportive communities and proper documentation are good assets for any library.

 

I like a lot of React's fresh ideas about VDOM, and component-based, and even JSX, but I feel like I dislike pre-compiling, translating, transpiling and totally any "pre-*".
I know that the process of building have become a must nowadays, But all of those abstraction feel awkward.

 

I also tend to dislike having to pre-compile things.

 

I use React professionally; but am happy enough switching between frameworks.

Likes:

  • easy enough to learn
  • component based
  • good employment prospects
  • powerful backing: it's going to be around for a while I guess
  • plenty of support/instructions available
  • flexible
  • available libraries
  • well established

Dislikes:

  • JSX: conditional output can sometimes feel clunky compared to a template-based approach; though Array.map(renderElement) is some consolation
  • state management - usually requires additional libraries like redux (the counterpoint to flexibility is that you have to do extra work yourself and everyone has a different idea of the best approach)
  • boilerplate (especially with redux)
  • payload: you have to ship the framework in your bundle
  • virtual DOM solves a problem that shouldn't be there (see Svelte below)
  • Accessibility (more an issue of how it gets used of course)
  • powerful backing isn't always a good thing: facebook aren't getting very good press in terms of their ethics lately
  • almost too popular: reduced competition can lead to stagnation and complacency. Too much noise when searching for solutions/libraries etc.

Alternatives:

  • Angular. More complete in that it provides structure for state management and an opinionated framework for adding things like services: less to think about; but less flexible and more to learn. Well established and backed by Google
  • Vue. I haven't used it but have heard good things. Seems to hit the sweet spot between React's flexibility whilst still providing a bit more structure
  • Svelte. Not yet properly established but pretty revolutionary: dispenses with the virtual DOM by compiling the framework functionality into the output. Achieves really good performance whilst keeping a comparatively tiny bundle size. Also has a really nice developer experience. I'd totally recommend it for small personal projects or as a more straightforward introduction to component-based frameworks. In the long term it still has to prove whether it works well at scale.
 

Thanks for your comment. I share several of your likes and dislikes.

You have intrigued me with Svelte. I'll have to add it to my list.

 

I am newbie dev and i jump from one language to another as fast as the company i work for completes projects. I find the whole single page arrangement fascinating.

 
Classic DEV Post from Jun 22

Do you have your own Gatsby site? Let's brainstorm a dev.to cross-poster

I'd love it if my blog posts were automatically sent to dev.to - wouldn't you?

SavagePixie profile image
Always learning new things. I love web development and coding in general.

Sore eyes?

dev.to now has dark mode.

Go to the "misc" section of your settings and select night theme ❤️