React Redux
Redux is an open-source JavaScript library for managing and centralizing application state.
What is Redux?
React-Redux is a popular state management library that helps manage the application state in React applications. React-Redux is a popular state management library that helps manage the application state in React applications.
Why Do We Need Redux?
As React apps grow, managing state between multiple components becomes complex. Props drilling (passing props through multiple layers) can become hard to maintain.
Redux solves this by:
- Centralizing state in a single global store.
- Making state predictable via a strict pattern: Actions → Reducers → Store → UI.

Concepts of React-Redux

Concept | Description |
---|---|
Store | The single object that holds the state of your whole app |
Action | A plain JS object that describes what happened |
Reducer | A pure function that takes current state and action, and returns new state |
Dispatch | A method used to send an action to the store |
Selector | A function to get specific data from the state |
Install Redux packages
React Redux Example 1
- Stores a username in Redux state.
- Allows changing the username using a form input.
Access and Update Username
- State managed via Redux Toolkit.
- useSelector and useDispatch used to read and update state.
React Redux Example 2
- Add items to a todo list and remove them
- Add a todo using the input and button.
- Delete any todo by clicking the "X" next to it.
- All state is handled via Redux.