Blog articles

6 reasons to use React (and a few reasons not to)

In React’s short six-year lifespan, it’s seen an impressive rate of adoption. It now finds itself among the top software development technologies, alongside stalwarts like MySQL and jQuery. With all the attention, many teams find themselves asking the inevitable follow-up question: Should we consider using React? While there’s no single answer for every dev team, here are six primary reasons why React is definitely worth looking at.

Flexibility

Depending on your priorities, React’s flexibility can offer a huge advantage. It allows you to determine how you want to handle routing, testing and even folder structure. Beyond the environment, the fact that React isn’t too opinionated means it can be used on a host of different projects: web applications, static sites, mobile apps and even VR. It’s supported by all major browsers, including older versions of IE, and will continue to see broad support due to its affiliation with Facebook. 

One other important aspect of React’s flexibility is its ability to be sprinkled into existing applications. Individual elements in a page can be replaced by React, until the entire application makes the transition. (This is actually how Facebook slowly moved from server-rendered PHP to client-side rendered React.)

Developer experience

Because the React API isn’t very large, many developers don’t find it necessary to constantly reference documentation. React offers the option of declaring classes or functions for components, which in turn allows HTML to be housed within JavaScript. This design is opposite to competitors like Angular or Ember, which require developers to learn a special syntax. Additional tools like Create React App further allow developers to customize their experience to individual needs.

Corporate investment

React was created by Facebook in 2011, and open-sourced in 2013. Facebook currently uses more than 50,000 React components in production, so there’s no questioning the company’s commitment to the project. In fact, React is supported by a full-time staff of committed developers who blog regularly about the development process. 

They also offer codemods to simplify the process of keeping code up to date. When a new version is released, these codemods give developers the ability to run a command line that automatically updates their code base.

Community support

React is in the top most starred repos on GitHub, and it’s downloaded more than 6.6 million times every week. But more important than the number of developers using React is the quality of their experience with the framework. In the 2019 State of JS survey, 72% of those who used React said they would use it again. 

For those who need support, the chat community Reactiflux offers rapid feedback, not to mention the hundreds of thousands of React-related StackOverflow answers available to peruse. With an ecosystem that includes popular names like React Router, React Redux and MobX, the community is second to none.

Performance

While React isn’t necessarily the absolute fastest framework available, its use of a virtual DOM helps it benchmark quite well compared to the competition. This saves battery and CPU, and simplifies the programming model by re-rendering the screen when necessary.

React’s size is definitely one of its most appealing attributes. Weighing in at just 32k, (or just 3k in the form of Preact), it’s a great option for teams looking to minimize page load times and data use.

Testability

Since many of React’s components are pure functions, automated testing doesn’t require mocking or subbing. While UI tests usually require a browser, React allows the ability to run unit tests and memory via Node. Single React components tested in isolation are reliable and deterministic because they are pure functions. 

Popular testing frameworks include Jest, Mocha and Jasmine, with Jest’s main advantage being its support by a full-time staff at Facebook and its bundling with Create React App.

The downsides

As with any new technology, it’s always important to methodically weigh benefits versus drawbacks and consider how it will impact the existing tech stack. Here are some of React’s trade-offs:

  • Because it's a library rather than a full framework, React requires more setup which can result in decision fatigue.
  • React trades being concise for being explicit. For example, two-way binding isn’t very common, so a change handler is required to keep things in sync. This results in more control, but also requires more code.

  • Options like Angular, View and Ember are more template-centric, which can be beneficial for teams who are new to JavaScript. React, on the other hand, requires a thorough knowledge of modern JavaScript.

  • React popularized the idea of a single component containing JavaScript and markup. This approach contrasts with the model view controller norm. While there are definite benefits to React’s approach, some may prefer separation.

  • React is technically non-standard, so those who are committed to the standard will want to stick with Web Components. This leads to a whole list of its own trade-offs, but is worth considering.

  • Facebook’s corporate backing can be a positive or a negative, depending on your perspective. As was mentioned above, the benefits of this include dedicated staff and funding. But those wanting to steer clear of Facebook likely don’t appreciate their involvement.

As more teams weigh the benefits of React, many of them are deciding to make the jump. While there are some definite downsides to consider, the framework’s flexibility, support, and the overall experience make it tough to beat.

To get a deeper view of the pros and cons of React, you can watch Cory House’s recent webinar here.