React JS — JavaScript the right way

React JS is a JavaScript library created by Facebook and made specifically for managing the user interface. It uses what’s called the “virtual DOM” to manage changes to the real DOM (what you see in the browser). It manages these changes really easily and quickly. A fun fact for you, React is used entirely to power the web app Instagram.

I’ve been meaning to write about React for some time now, after picking it up a while ago. I realised that something had to change when I was writing JavaScript — it didn’t feel natural to be writing a heap of jQuery to change DOM elements or whatever crazy thing that was required. It’s not the end result that is wrong, it was the process of ripping things apart.

Why React?

I found React to be a low-investment/high-return kind of library. React is very small, so on the one hand you don’t need to put too much effort into learning the basics (enough to be comfortable to use it in production) and it’s a breeze to get started into your existing projects. In my case, I’ve been integrating it with SilverStripe.

There’s good documentation for React around on Facebook’s github profile, so be sure to read through before getting started to check out some examples.

I’ve used React for a few side projects, a few websites that are in production, and it’s definitely my go-to library for making complex web apps or UI structures that would otherwise leave me scratching my head.

A few times before, I’ve written all of this code in JavaScript, and not been happy with the end result because it still feels too cumbersome. 
At the end of the day, I want to make sure someone else can come in and understand what my code is doing and I think React gives people a clear structure to do that, along with many cool features, which I haven’t mentioned.

To sum up

I guess it’s not so much that React is better than any other JavaScript library, it’s about using what’s right for the project and in most cases I’ve found React useful, other times it’s probably overkill — it depends what you’re doing. These smaller libraries are becoming very popular though, and for good reason — they’re easier to get started and integrate into your existing tech stack. So give React a go, and see what you think.

Originally published at