A library is code that other developers have written. Although React is often called a framework, this is not entirely true: the developer uses the code from the library in his program, and the code from the framework uses the developer’s code in itself. The library is a garage with cars, scooters, bicycles — you can take any transport and go wherever you want; a framework is a bus that you can put passengers on to get them from point A to point B.
To understand how React works and what its feature is, you need to understand two approaches to programming: imperative and declarative. Let’s do this on the example of a taxi.
- If a passenger tells a driver: turn the steering wheel to the right, and now to the left, press the gas pedal, press the brake, — then this is an imperative approach. The passenger describes each action of the taxi driver to get the result.
- If the passenger says the address, and the driver builds the route, monitors the gears and turns, — this is a declarative approach. The passenger describes the end result (the point at which you need to arrive) and the reaction to external events such as “if we get stuck in traffic, drop me off at the subway.”
React.js works on the idea of a declarative approach. This is called “UI — data function”: the developer describes how the interface behaves depending on data and events, for example:
- for each user in the chat, draw a cross button in the list with avatars;
- if the user clicked on the cross, remove from the list of users the one close to whose avatar this cross is.
Descriptions of UI blocks in React.js become the components from which the interface is assembled. Components are forms, buttons, fields, and application screens. The developer creates them himself or takes them from third-party libraries. It can also nest components inside each other, reuse or edit at once:
- the developer describes the component using React
- specifies all places where this component is rendered
- React adds components to HTML
- if the developer needs to modify a component, for example, change the color of a button, he specifies a new color for the desired component
- React changes the color of all buttons, in all places where this component is displayed. No one forbids making the button color customizable for each specific component.
The trick is that creating and configuring components are separate processes. First, the developer explains how a component, such as a button, looks and behaves, and what properties can be configured. And then it places button configurations in different places, conditionally: in the form — medium green, in the bin — large yellow, on the main screen — small gray.
Digiteum’s experience suggests that React allows you to:
- choose which libraries to use, for example, to control screen transitions and store data
- change development tools
- make an application entirely in React or use it for one feature
- Great DevX — developer experience — how convenient, comfortable and easy it is for a developer to interact with technology.
- managed to find solutions for all typical problems
- came up with thousands of tools that make the life of a developer easier
- formed a gigantic and ever-growing ecosystem around the library
- the library has many users, there is someone to learn from and ask for advice.
1. Poor documentation
ReactJS is a relatively new technology and it continues to evolve with developers contributing to it and expanding its capabilities. But the documentation for React and related libraries is often lacking.
2. Confusing JSX Syntax
3. The complexity of search engine optimization
4. Focus on the user interface
React is not an all-in-one tool for building an entire application. Therefore, if you follow the Model-View-Controller design pattern, then React will only be responsible for the view.
React has been successfully proven to be effective in creating interactive user interfaces, which is why it is so widely used. React has many advantages, but when building an app for business development, you should be aware of the disadvantages. For an expert assessment of the project, it is better to contact a specialist, such as in the Digiteum company.