# Combining Multiple Reducers

## Combining Multiple Reducers

Since Redux store only takes one reducer, we need to combine multimple reducers into one root reducer then pass it down to the store.

## Combining Reducers with `combineReducers()`&#x20;

{% tabs %}
{% tab title="rootReducer.js" %}

```jsx
// Import the combineReducers function from the Redux library
import { combineReducers } from "redux";

// Import the counterReducer and dynamicCounterReducer functions
import counterReducer from "./counter/counterReducer";
import dynamicCounterReducer from "./dynamicCounter/dynamicCounterReducer";

// Define the rootReducer by calling combineReducers and passing in an object that maps reducer functions to keys
const rootReducer = combineReducers({
  counterReducer,
  dynamicCounterReducer,
});

// Export the rootReducer as the default export of this module
export default rootReducer;

```

{% endtab %}

{% tab title="store.js" %}

```jsx
// Importing the 'legacy_createStore' function from Redux
import { legacy_createStore as createStore } from "redux";

// Importing the root reducer for the Redux store
import rootReducer from "./rootReducer";

// Creating the Redux store using the 'createStore' function
const store = createStore(rootReducer);

// Exporting the created store as default
export default store;

```

{% endtab %}
{% endtabs %}
