Why React is the future of JS development?

I have been using React for almost a year now. Today I will share with you why I think this library is the future for building fast, reliable frontend interfaces.

There is an explosion in Javascript frameworks which can be overwhelming especially to new JS developers. While every library or framework tend to solve certain problems and make development much easier, it’s hard to keep up to date with them all.

react

React’s performance is second to none

If your UI is lagging or is unresponsive for some time, it can cause users an unpleasant experience with your product.

Feature one for every project should be performance. This is an area where React excels in (unbeatable). It creates a copy of your DOM called the virutal DOM. When a state or a prop is modified, it re-renders that component and changes are made to the vDOM. It then compares the vDOM with the actual DOM and makes changes only to the affected document nodes .

JSX Syntax

JSX syntax is one of the library’s biggest advantages. It basically allows your to write HTML markup in Javascript. You will need babel to transpile that into JS.

Code reusability

Build encapsulated components that manage their own state, then compose them to make complex UIs. Since component logic is written in JavaScript instead of templates, you can easily pass rich data through your app and keep state out of the DOM. This will allow you to write re-usable components that you can use in other projects.

React had a Javascript-centred design. It brings the presentation into the logic.

Debugging

When something goes wrong, it can be pain in the back to debug a JS code after it has been bundled. When you make a typo in React, it won’t compile and it shows you exactly where your error is. This behaviour radically speeds development.

Learning curve

Talking from a personal perspective, it takes only a few days to get to know React. It takes more to get used to the Flux Architecture and the single way data flow. Once you do, it becomes evident (and must-use especially for large projects). To read Angular you have to learn a set of Angular-specific syntax (called directives). To read React, learn Javascript.

Used in production

Facebook and Instagram use React in production on their websites. What drove me away from Angular is that v2 is not backward compatible with code written in v1.5. This means that you will not be able to upgrade a 1.5 app to Angular 2, or you will have to re-write your app in Angular 2. This is not the case with React since it is used in prod.

Lightweight

As the time of writing this article, version 15.3.2 takes only 147Kb (minified) of disk space. Keep in mind that React does not come with a router, animation helpers or an architecture implementation out of the box. Even if you add those, it won’t take more than 200Kb.

Finally

I choose React most of the time because it makes development much easier and errors more predictable. What do you think of React? Which librairies do you use?


Leave a Reply

Your email address will not be published. Required fields are marked *