State Management with Redux

React js 12 min min read Updated: Feb 25, 2026 Advanced

State Management with Redux in React js

Advanced Topic 4 of 15

Redux State Management in React JS

When building small React applications, managing state with useState or useContext works perfectly fine. But as the application grows - multiple pages, shared data between components, API integration, authentication, carts, dashboards - state management starts becoming complicated. Props drilling increases, logic gets duplicated, and debugging becomes harder.

This is where Redux comes into the picture. Redux provides a predictable and centralized way to manage state across the entire application. Instead of passing data from parent to child to child, Redux allows any component to access global state directly.


What is Redux?

Redux is a state management library that helps you manage application-level state in a predictable way. It is not limited to React, but it is most commonly used with React applications.

The core idea of Redux is simple:

  • There is a single source of truth (the Store).
  • State is read-only (cannot be modified directly).
  • Changes are made using pure functions called reducers.

Think of Redux as a central storage room. Instead of every component keeping its own copy of data, all data is stored in one place, and components simply read from it or request changes.


Why Do We Need Redux?

1. Avoid Props Drilling

In large applications, passing props through many levels becomes messy. Redux eliminates this by allowing components to access global state directly.

2. Predictable State Updates

Redux enforces strict rules for updating state. This makes debugging easier and improves maintainability.

3. Centralized Logic

Instead of scattering business logic across components, Redux keeps it structured and organized.

4. Easier Debugging

With Redux DevTools, you can see every action dispatched and track state changes step by step.


Core Concepts of Redux

1. Store

The store is the central place where the entire application state is stored.

2. Action

An action is a simple JavaScript object that describes what happened. It must have a type property.

3. Reducer

A reducer is a pure function that takes the current state and an action, and returns a new updated state.

4. Dispatch

Dispatch is the method used to send an action to the reducer.


Basic Example - Counter Application

Step 1: Install Redux Toolkit

Redux

npm install @reduxjs/toolkit react-redux

Redux Toolkit is the recommended way to write Redux logic today. It simplifies configuration and reduces boilerplate code.


Step 2: Create a Slice

Redux

import { createSlice } from "@reduxjs/toolkit";

const counterSlice = createSlice({
  name: "counter",
  initialState: {
    value: 0
  },
  reducers: {
    increment: (state) => {
      state.value += 1;
    },
    decrement: (state) => {
      state.value -= 1;
    }
  }
});

export const { increment, decrement } = counterSlice.actions;
export default counterSlice.reducer;
  

Here, we created a slice which contains state and reducer logic together.


Step 3: Configure Store

Redux

import { configureStore } from "@reduxjs/toolkit";
import counterReducer from "./counterSlice";

const store = configureStore({
  reducer: {
    counter: counterReducer
  }
});

export default store;
  

The store connects all reducers and becomes the single source of truth.


Step 4: Provide Store to React App

Redux

import React from "react";
import ReactDOM from "react-dom";
import { Provider } from "react-redux";
import App from "./App";
import store from "./store";

ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  document.getElementById("root")
);
  

The Provider makes Redux store available to all components.


Step 5: Use Redux in Component

Redux

import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { increment, decrement } from "./counterSlice";

function Counter() {
  const count = useSelector((state) => state.counter.value);
  const dispatch = useDispatch();

  return (
    <div>
      <h2>Count: {count}</h2>
      <button onClick={() => dispatch(increment())}>Increment</button>
      <button onClick={() => dispatch(decrement())}>Decrement</button>
    </div>
  );
}

export default Counter;
  

Here:

  • useSelector reads data from store.
  • useDispatch sends actions to update state.

How Redux Flow Works

The data flow in Redux always follows one direction:

  1. User clicks button.
  2. Action is dispatched.
  3. Reducer updates state.
  4. Store saves new state.
  5. Component re-renders automatically.

This predictable flow makes Redux powerful and easy to debug.


When Should You Use Redux?

  • Large-scale applications
  • Multiple components need same data
  • Complex business logic
  • Frequent API state handling
  • Authentication and role management

For small projects, Redux may feel unnecessary. But for enterprise-level applications, it becomes extremely useful.


Advantages of Redux

  • Centralized state management
  • Predictable updates
  • Better debugging tools
  • Clean architecture
  • Easy to scale

Limitations of Redux

  • More setup compared to useState
  • Learning curve for beginners
  • Too much boilerplate without Redux Toolkit

Final Thoughts

Redux is not just about managing state - it is about structuring your application in a disciplined and predictable way. While modern React offers alternatives like Context API and Zustand, Redux still remains one of the most reliable solutions for handling complex state logic in large applications.

If you understand how store, actions, reducers, and dispatch work together, you can confidently build scalable React applications without worrying about messy state management.

What People Say

Testimonial

Nagmani Solanki

Digital Marketing

Edugators platform is the best place to learn live classes, and live projects by which you can understand easily and have excellent customer service.

Testimonial

Saurabh Arya

Full Stack Developer

It was a very good experience. Edugators and the instructor worked with us through the whole process to ensure we received the best training solution for our needs.

testimonial

Praveen Madhukar

Web Design

I would definitely recommend taking courses from Edugators. The instructors are very knowledgeable, receptive to questions and willing to go out of the way to help you.

Need To Train Your Corporate Team ?

Customized Corporate Training Programs and Developing Skills For Project Success.

Google AdWords Training
React Training
Angular Training
Node.js Training
AWS Training
DevOps Training
Python Training
Hadoop Training
Photoshop Training
CorelDraw Training
.NET Training

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators