React is a library originally in order to create a component in web applications (React DOM). It has expanded to other systems such as mobile apps (React Native) or virtual reality (React VR).
Working with React means you are creating an web application through components. Each page does not contain everything in a single file anymore. Many components are combined together. This approach might be confusing you at first. But in the end, you will create a new page with existing components, which work consistently across the many pages.
Before React, two-way binding was very popular (ex. Angular), which magically syncs the data state and UI. React adopts the one-way binding, which requires the explicit change handler to set the new state. However, this additional overhead has some benefits too. Two-way binding seems good but it make really hard to debug when the things do not work correctly. Also one-way binding makes you to have more control of how the state flows.
React is a very lightweight and non-opinionated library that is very flexible. There are many React renderers that can be used in many echo systems (react-dom, react-native, etc.).
There are other reasons why we might want to use React; for example, its community support and popularity. But the most important factor is its performance to update the DOM. React minimizes DOM changes with virtual DOM.
4. Related Libraries
React is usually used with other libraries. The choice can be overwhelming but there are popular options.
- Type Enforcement: PropTypes, TypeScript
- State Management: Redux, Flux
5. All but Goodies?
React is simple and straightforward so it is easy to learn. But don’t be fooled. Note that React is a library specifically designed to create components rather than a full framework (Angular). React needs other libraries to create the whole solution. You need Redux for data, React-Router for Routing, etc …
In my experience, React is a great tool to create reusable components but interacting with Redux is not as simple as you might guess. There require quite a lot of plumbing code you will tackle. However, with careful design and coding, you can create consistent component web applications with React and Redux, which work like a magic.