Top 5 Reasons to Use React

Alex Richards
Feb 15 · 6 min read

If you plan on using a JS framework or library, my very first suggestion for you would be to learn React. Developed by Facebook, React was first released on May 29, 2013, and is now the most popular library for front end web development. But how did it become so popular and why do so many developers today use it on such a regular basis? To answer these questions, let’s take a look at five reasons why so many people use React and why you should be too.

Image for post
Image for post
Image for post
Image for post

1.) The Virtual DOM

First of all, you can think of the DOM (Document Object Model) as a place where all the objects on a web page are stored. The unique thing about the DOM is that it organizes these objects in a tree-like structure as you can see below.

Image for post
Image for post

Most other JavaScript libraries and frameworks use what is known as the real DOM. The problem with the real DOM, however, is that the whole thing has to update each time there’s a change in your UI’s state from the top down. This is a fairly straight forward process but updating the DOM multiple times can slow things down quite a bit and can be quite expensive, this is where the virtual DOM comes in.

The virtual DOM is essentially a copy of the real DOM, but the virtual DOM doesn’t actually change anything that you see on the screen which is why it’s so fast. Essentially, the virtual DOM is like taking a screenshot of the real DOM and then saving it later.

Once the virtual DOM updates, it compares the updated version with a previous version of the virtual DOM. React then compares both versions of the virtual DOM to see what has changed through a process known as diffing and only applies those changes to the real DOM.

Image for post
Image for post

This way, instead of going through the entire tree and updating each object contained within it, we only have to update the parts that change. This is one of the big reasons why React is so fast and why it’s gained the popularity that it has today.

Image for post
Image for post

2.) JSX

JSX is a syntax used in React that makes web development a whole lot easier. JSX essentially combines elements of both Javascript and HTML and puts them together in one package.

const name = 'Alex';
const jsxExample = <h1>Hello, {name}!</h1>;

As you probably guessed “Hello, Alex!” is what will be displayed on the page. If you would like to play around with some JSX yourself before installing React, you can do so here. JSX can also be used in functions, if statements, loops, variables, and just about anywhere where you can use regular JavaScript. You’ll notice that we still use camel case when using JSX, this is because JSX is still more similar to JavaScript than it is to HTML. If you’d like to learn more about JSX you can watch this video which goes into greater depth:

Some developers don’t like to use JSX but this is no reason to worry because React doesn’t force you to use it. If you’d like, you can continue using JS and HTML like normal so you can think of JSX as a bonus feature of React that can help you speed up development.

Image for post
Image for post

3.) React is a Library

Although you might see React referred to as a JavaScript framework by many, the actual fact is that it is a library, not a framework. To understand the difference between frameworks and libraries, start by thinking of the differences between these two different sandwiches.

Image for post
Image for post

You can imagine a framework as being the so-called “skeleton” of both sandwiches. Both have bread on the outsides followed by vegetables, cheese, and meat on the inside in that order from the top down. However, even though both of these sandwiches both contain this same structure, you can tell just by looking at them that they are going to taste pretty different because of the different ingredients inside (libraries).

So, the difference between a framework and a library is that a framework’s structure is already determined before you begin whereas a library is not. This means that a library gives you much more flexibility and customization than a framework does.

To get a little more technical instead of comparing two different sandwiches, a library essentially allows you to control the flow of your app. When you’re using a library, you are the one who calls the library but when you’re using a framework, it calls you. This is known as inversion of control.

Image for post
Image for post
Image for post
Image for post

4.) React is Popular

Over the past few years, React has exploded in popularity and is now the #1 JavaScript library out there today. Take a look at how React stacks up against other libraries and frameworks that are also popular.

Image for post
Image for post

As you can see, there’s basically nobody who hasn’t heard of React and only a small percentage of those don’t have an interest in it or wouldn’t use it again. React’s popularity comes from its speed (Virtual DOM), reusable components, easy learning curve, and its developer tools and support. This also means that if you’re looking for employment, React is going to be your best choice when it comes to other libraries and frameworks out there.

Image for post
Image for post

5.) Mobile Apps With React Native

Although it’s not exactly the same as React, React Native allows you to create mobile apps for both Android and IOS. The syntax isn’t exactly the same as regular React, however, React Native is still extremely similar and won’t take you long to learn if you’re already familiar with React or even just plain JavaScript.

If you don’t have a Mac and have an interest in creating mobile apps for IOS, then React Native is for you. React Native can also be used for developing for both IOS and Android simultaneously and is written with JavaScript and JSX just like regular React. React Native was released back in 2015 and is still somewhat new and has lots of room to be improved and expanded on. If you would like to look at React Native in greater detail you can click the link below:

JavaScript In Plain English

New JavaScript + Web Development articles every day.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store