What is React?
If you’ve been working with the web recently you probably have heard of React. It is a flexible library rather than a full-featured framework. So, more like Flask than Django. It centers around building UIs with a component-based approach, favoring composition over inheritance if thinking in terms of object-oriented design.
One of the coolest things about React is the Virtual DOM. At a high level it means super high performance as it’s only updating the parts that have changed and it determines this by diffing an in memory representation of the DOM. You can read the Reconciliation article for a detailed explanation of how it all works. What it means for the developer is that you never have to worry about what parts of the display to change, which anyone who has built out applications with jQuery knows what a nightmare that can become to try and maintain.
Being component-centered in building up UIs, it is also declarative. In essence, your UI is a function of inputs (properties and state), rather than the result of imperative event-driven DOM manipulation. This makes it faster, easier to debug, and much cleaner to reason your way through your code base as it grows.
Check out Thinking in React for a more detailed discussion.
Why use React?
When deciding on a library or a framework and an approach in general to taking on a new project there are a lot of considerations one must make. There are five key reasons that you should consider React for your next UI-intensive app:
- It is battle-tested. There are now many enterprise-level apps using React in production.
- It enables fast, responsive UI. An important element for keeping users engaged and happy is not making them wait.
- It reduces complexity. Because of it’s declarative nature and one-way data flow, it’s much easier to debug than an app built on event-driven DOM manipulation.
- It encourages code reuse. The component oriented nature lends itself to code reuse and as your project grows, you will see a non-trivial reduction in development time required for additional features.
- It makes it easy to add a native app.. While you won’t necessarily reuse your components meant for the web, the API you have developed as well as the techniques and patterns applied as easily transferrable to building React Native components for iOS and/or Android.
Between risk reduction and code reuse, React will save you time and money over the long-term.