Why React

Reasons why React has become so popular so quickly:

  • Working with the DOM API is hard. React basically gives developers the ability to work with a virtual browser that is more friendly than the real browser. React’s virtual browser acts like an agent between the developer and the real browser.
  • React enables developers to declaratively describe their User Interfaces and model the state of those interfaces. This means instead of coming up with steps to describe transactions on interfaces, developers just describe the interfaces in terms of a final state (like a function). When transactions happen to that state, React takes care of updating the User Interfaces based on that.
  • React is just JavaScript, there is a very small API to learn, just a few functions and how to use them. After that, your JavaScript skills are what make you a better React developer. There are no barriers to entry. A JavaScript developer can become a productive React developer in a few hours.

But there’s a lot more to it than just that. Let’s attempt to cover all the reasons behind React’s rising popularity. One reason is its Virtual DOM (React’s reconciliation algorithm). We’ll work through an example to show the actual practical value of having such an algorithm at your command.

React’s official definition states that it’s a JavaScript library for building User Interfaces. It’s important to understand the two different parts of this definition:

  • React is a JavaScript library. It’s not a framework. It’s not a complete solution and we’ll often need to use more libraries with React to form any solution. React does not assume anything about the other parts in any full solution. It focuses on just one thing, and on doing that thing very well.
  • The thing that React does really well is the second part of the definition: building User Interfaces. A User Interface is anything we put in front of users to have them interact with a machine. User Interfaces are everywhere, from the simple buttons on a microwave to the dashboard of a space shuttle. If the device we’re trying to interface can understand JavaScript, we can use React to describe a User Interface for it.

Since Web browsers understand JavaScript, we can use React to describe Web User Interfaces. I like to use the word describe here because that’s what we basically do with React, we just tell it what we want and React will build the actual User Interfaces, on our behalf, in the Web browser. Without React or similar libraries, we would need to manually build User Interfaces with native Web APIs and JavaScript.

When you hear the statement that “React is declarative,” this is exactly what it means, we describe User Interfaces with React and tell it what we want (not how to do it). React will take care of the “how” and translate our declarative descriptions (which we write in the React language) to actual User Interfaces in the browser. React shares this simple declarative power with HTML itself, but with React, we get to be declarative for HTML interfaces that represent dynamic data, not just static data.

Other benefits of using react are

  • Uses virtual DOM which is a JavaScript object. This will improve apps performance, since JavaScript virtual DOM is faster than the regular DOM.
  • Can be used on client and server side as well as with other frameworks.
  • Component and data patterns improve readability, which helps to maintain larger apps.
  • There are a ton of resources for learning React. The community is extremely helpful and there are a multitude of free online resources to help you get started.
  • You can easily integrate React components into legacy code. This makes it much easier to update legacy code bases.
  • The Virtual DOM is extremely efficient at rendering web applications.
  • The React CLI makes it extremely easy to scaffold an application. With one command you can quickly begin developing your app.
  • Component structure is easy to test. Since components are modular, unit testing becomes much easier with Jest and Enzyme.
  • Components are reusable and can be nested for easy application composition. With components, you can build your application similar to how you would build a Lego house.
  • Component styling is scoped to each component. Now, you can harness the power of CSS specificity and get rid of all those pesky !importants.
  • Components have their own state which makes it easy to work with data. It’s much easier to keep track of the state of your data and pass them as properties to child components.
  • Lifecycle methods provide an easy was to interact with the component during mounting, when receiving data or props, and more.

Limitations of React

  • Covers only the view layer of the app, hence you still need to choose other technologies to get a complete tooling set for development.
  • Uses inline templating and JSX, which might seem awkward to some developers.
Share this post
[social_warfare]
React Features
React Design Principles

Get industry recognized certification – Contact us

keyboard_arrow_up