React is not a framework

Make No Assumptions

React JS has grown rapidly in popularity among web developers. As of this writing it has 26,000+ stars on github. Its popularity has unfortunately led to it being misconstrued as something it isn’t – a framework. Many people are making comparisons between React and other popular JS libraries – seemingly based on the fact that they’re both popular JS libraries.

This doesn’t make sense. React’s own site states:

“Lots of people use React as the V in MVC. Since React makes no assumptions about the rest of your technology stack, it’s easy to try it out on a small feature in an existing project.”

Why people compare a V library to an entire MVC framework is beyond me. I’ve been told that I should “ditch Angular and go to React”. The model and view part of the equation were left out.

 

The Google

Just look at these completions:

react vs completions

The most common comparison is of course, Angular. Why? Presumably because its popular and from a big tech company just like React. Let’s look at the search results:

Screen Shot 2015-08-11 at 10.36.48 AM

To be fair, some of these results are comparisons on a performance basis pitting the View portion of Angular’s MVC architecture against React. This usually takes place with an ng-repeat facing off against its React analog. React usually wins (but using Angular’s “track by” makes that marginal).

 

The Useful Comparison

A more helpful comparison of the two would be based on features

Angular has:

  • Two-way data-binding
  • Dependency injection
  • jqLite
  • controllers
  • directives
  • services
  • filtering
  • routing
  • etc

React has:

  • a tool for DOM manipulations

React doesn’t have the features that Angular has. Who cares? Oranges don’t taste like salad, why should they? React doesn’t care about dependency injections, React doesn’t care about data models, React doesn’t care about controllers, React doesn’t make REST calls, React doesn’t organize business logic. React follows the unix philosophy. React does one thing and does it well – manipulates the DOM.

Comparing it to Angular (or any other framework) does a disservice to both, because on paper React will lack features and Angular will be slower since view performance is the only way to compare them (is doing an ng-repeat over thousands of items a good idea for UI anyway?).

 

Flip the script – React & Angular

Moreover you can use React inside of Angular! There’s no reason for this to be mutually exclusive. You don’t need to “ditch Angular for React”

Make your own directive that uses react like https://github.com/dhcar/angular-react. Or use a library like https://github.com/davidchang/ngReact.

If your question is “should I use React or Angular?” then you’re asking the wrong question because its never “React vs Angular”, its “React + xyz vs Angular” or better yet “React + Angular”.

 

Here are some better questions to ask:

  • Do I want one framework or multiple libraries?
  • Do I like React’s syntax?
  • Do I like Angular’s dependency injection?
  • Should I use React and Angular together?
  • Why do people pit two Javascript libraries against each other because they’re both popular?
No comments yet.

Leave a Reply