DeveloperHandbook.com

What is React.js, and why use it?

Published


React is a tool for building dynamic and interactive user interfaces.

React promotes building small pieces, called components, (which are often JavaScript functions or classes), that are assembled to form a UI. Notice that we have not used the word “web” or “page” here, because React itself is view-layer agnostic, meaning a separate view renderer is used to create a UI for the user to consume.

React is not a framework, like Angular. React is an unopinionated library that, when combined with a renderer, can display/capture data and respond to user inputs and network events.

As React is view-layer agnostic, you, the developer, are not limited to using React to build for the web.

React is closely associated with ReactDOM, which understands how to render markup in the browser, and ReactNative, which understands how to render a mobile friendly native view.

What problems does React solve?

React attempts to solve the following problems;

By doing the following;

In a nutshell, React is fast, structured, and easier to maintain for teams of developers.

Do you even need a library/framework?

We have spoken a lot so far about React and what it brings to the table, but do you even need a framework/library at all?

Short answer: yes.

Long answer: no, but.

Explanation Strictly speaking, with investment in time and effort, you can build dynamic websites yourself without a framework.

At a minimum, your website will probably need some of the following features;

Yes, you can build a website that is dynamic and interactive yourself using plain old JavaScript. You might want to ask yourself why would you want to do this? Why not use an off-the-shelve lightweight, feature rich library that was built by some of the smartest people in our industry (including community contributors of course!).

One killer feature of React that really propels it to the next level, in my humble opinion, is the distinct lack of React code that ends up in the code base. React is unopinionated and gets out of my way, leaving me with code that is largely just native JavaScript anyway, with very few React language specific paradigms.

The React learning curve is minimal. React is fast, lightweight, and feature rich. If you already know JavaScript, you are already 90% on your way to knowing React.

Enough said.

Summary

React is a fast, lightweight, feature rich library that helps us build dynamic web and mobile applications. You probably want to use React because it promotes small, reusable pieces called components, which promotes structure and consistency. React helps you to write more robust, easier to maintain code especially for larger teams of developers. React is very performant, which it achieves, in part, by intelligently patching the DOM when the state of your components changes. React is not strictly necessary to build a modern website today, you could roll-your-own framework, but the rich out-of-the-box feature set can help you build quality websites more rapidly.