What are combinedReducers in React Redux? Last Updated : 28 Apr, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report In React Redux 'combinedReducers' is like putting together smaller pieces of a puzzle (reducers) to form one big puzzle (the root reducer). It helps manage your application state more efficiently by organizing and combining these smaller pieces, making your code cleaner and easier to maintain. Key Features of combinedReducers in React Redux:Organize your app's state management by breaking it into smaller, more manageable pieces.Combines these smaller pieces (reducers) into a single, connected state tree.Simplifies debugging and maintenance as your app grows by keeping related logic separate.Enables modularity and reusability of reducers, making adding or modifying features easier.Improves performance by allowing selective updates to specific parts of the state tree rather than re-rendering the entire app.Example: Below are the example of combinedReducers in React Redux. Install the necessary package in your application using the following command.npm install react-redux npm install redux JavaScript // index.js import React from 'react'; import { createRoot } from 'react-dom/client'; import { Provider } from 'react-redux'; import { createStore } from 'redux'; import App from './App'; import rootReducer from './reducers/rootReducer'; const store = createStore(rootReducer); const root = createRoot(document.getElementById('root')); root.render( <Provider store={store}> <App /> </Provider> ); JavaScript //App.js import React from "react"; import "./App.css"; import Sample from "./Sample"; const App = () => { return ( <> <Sample/> </> ); }; export default App; JavaScript // todoReducer.js import { ADD_TODO, REMOVE_TODO } from "../constants/TodoActionTypes"; const initialState = { todos: [] }; const todoReducer = (state = initialState, action) => { switch (action.type) { case ADD_TODO: return { ...state, todos: [...state.todos, { id: Date.now(), text: action.payload.text }] }; case REMOVE_TODO: return { ...state, todos: state.todos.filter (todo => todo.id !== action.payload.id) }; default: return state; } }; export default todoReducer; JavaScript // settingsReducer.js const initialState = { darkMode: false, notifications: true }; const settingsReducer = (state = initialState, action) => { switch (action.type) { case 'TOGGLE_DARK_MODE': return { ...state, darkMode: !state.darkMode }; case 'TOGGLE_NOTIFICATIONS': return { ...state, notifications: !state.notifications }; default: return state; } }; export default settingsReducer; JavaScript // rootReducer.js import { combineReducers } from 'redux'; import userReducer from './userReducer'; import settingsReducer from './settingsReducer'; const rootReducer = combineReducers({ user: userReducer, settings: settingsReducer, }); export default rootReducer; JavaScript // actions.js // Action types for user export const UPDATE_USER = 'UPDATE_USER'; // Action types for settings export const TOGGLE_DARK_MODE = 'TOGGLE_DARK_MODE'; export const TOGGLE_NOTIFICATIONS = 'TOGGLE_NOTIFICATIONS'; // Action creators for user export const updateUser = (userData) => ({ type: UPDATE_USER, payload: userData }); // Action creators for settings export const toggleDarkMode = () => ({ type: TOGGLE_DARK_MODE }); export const toggleNotifications = () => ({ type: TOGGLE_NOTIFICATIONS }); JavaScript // store.js import { createStore } from 'redux'; import rootReducer from './reducers/rootReducer'; const store = createStore(rootReducer); export default store; CSS /* Sample.css */ .container { max-width: 600px; margin: 0 auto; padding: 20px; background-color: #f8f8f8; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } .user-info, .app-settings { margin-bottom: 20px; } .dark-mode { background-color: #333; color: #fff; } .button { padding: 10px 20px; background-color: #007bff; color: #fff; border: none; border-radius: 4px; cursor: pointer; transition: background-color 0.3s ease; } .button:hover { background-color: #0056b3; } Start your application using the following the command. npm startOutput: Output Comment More infoAdvertise with us Next Article What are the 3 core concepts of React Redux ? F faheemakt6ei Follow Improve Article Tags : Web Technologies ReactJS MERN-QnA WebTech-FAQs Similar Reads What are middlewares in React Redux ? In React Redux, middlewares are an essential concept for handling side effects and enhancing the functionality of Redux. They are used to intercept actions sent to the Redux store and modify them before they reach the reducer or after they are dispatched.Understanding ReduxBefore diving into middlew 5 min read What are Action's creators in React Redux? In React Redux, action creators are functions that create and return action objects. An action object is a plain JavaScript object that describes a change that should be made to the application's state. Action creators help organize and centralize the logic for creating these action objects.Action C 4 min read What are the 3 core concepts of React Redux ? Redux is a widely-used state management library that helps in managing the state in our projects. However, it comes with its own terminologies and jargon that can be confusing for beginners. Essentially, Redux comprises of three core concepts: actions, reducers, and store. In this article, we will c 4 min read Introduction to React-Redux React-Redux is a popular state management library that helps manage the application state in React applications. It is an essential tool in the React ecosystem, allowing you to efficiently handle complex state logic and data flow within large applications. React-Redux connects the Redux store to Rea 7 min read What are the differences between Redux and Flux in ReactJS ? During the phase of applications or software development, we gather the requirements of customers to create a solution to solve the problem of customers or businesses. To solve problems we rely on different technologies and architecture patterns. for a long time, developers were using MVC (Model-Vie 10 min read What is Logger middleware in React Redux ? Logger middleware is a tool that helps users understand what's happening behind the scenes in their Redux-powered React applications. It logs information about each action that gets dispatched in your app, along with the state before and after the action is processed. Syntax:import { createStore, ap 3 min read Like