DEV Community

Discussion on: Why do you use React?

Collapse
 
bartmr profile image
Bartmr • Edited

I use React because:

  • I can lazy-load components and services based on where they are in the navigation. I can just have a huge navigation tree with dozens of nested pages, and just cut a branch and say "this branch of the navigation will only be loaded if I need it". In Angular I have to create NgModules and move files and have dependencies load in a main module which might not be present in other stuff or whatever.
  • Hot-reload (saving a file, the code gets updated and changes appear on the screen without having to refresh the page) works like a charm
  • Can reuse mobile components in web pages.
  • Data can (or should) only go one way
  • Higher Order components
  • No inheritance. Only composition
  • React Context lets me detect the background color of a parent component, allowing me to change text color on runtime if it doesn't have enough contrast. Really useful for dark theme switch while using an app or website.
  • Debugging errors in components is super easy. Because React is just a thin View layer
Collapse
 
nickylewlew profile image
Nick Lewis

Awesome, thanks for this!

There are certainly some nice aspects about it that you're describing.

What would you say the learning curve is like for someone who hasn't worked with a component tool like React before?

Do you have any helpful resources for learning?

Collapse
 
bartmr profile image
Bartmr • Edited

You can do stuff pretty quickly in React and Redux in now time. More faster than Angular because Angular is split in several modules and its own workflow. React can be used however you like it. You can even have normal HTML pages with sections made in React. The thing is, with experience, you will always find better ways to do stuff. The first one will problably be "Holy sh**, if I had made my app in way A instead of way B, changing to server side rendering would be a single line of code".
It's been two years since I started developing apps and webpages with React from scratch, and I always find new ways to make better and more easily editable code. Starting with React is easy. Being a pro and doing changes like it's a photoshop document, that's the hard part. To summarize my opinion, here's a meme.

Meme