What Is React and How Does It Works
What Is React and How Does It Works
}
It’s possible to have as many components as
necessary without cluttering your code.
State Management
A state is a JavaScript object that represents a
part of a component. It changes whenever a
user interacts with the application, rendering a
new UI to reflect the modifications.
State management refers to the practice of
managing React application states. It includes
storing data in third-party state management
libraries and triggering the re-rendering process
each time data is changed.
A state management library facilitates
communication and data sharing between React
09/11/2024 Web Application Development 7
components. Several third-party state
Redux
The Redux state management library has a
centralized store, which keeps the state tree of
an application predictable. The library also
reduces data inconsistency by preventing two
components from updating the application’s
state simultaneously.
Redux’s architecture supports error logging for
easier debugging and has a strict code
organization method, simplifying maintenance.
Additionally, it features a large number of add-
ons and is compatible with all UI layers.
That said, Redux is rather complex and hence
suboptimal for small applications with a single
data source.
09/11/2024 Web Application Development 8
Recoil
Recoil is a JavaScript state management library
released by Facebook. It employs pure functions
called selectors to calculate data from
updateable units of the state known as atoms.
Multiple components can subscribe to the same
atom and thus share a state.
The use of atoms and selectors prevents
redundant states, simplifies code, and eliminates
excessive re-renders of React and any child
components. Recoil is more suitable for
beginners than Redux because its core concepts
are considerably easier to grasp.