2018-10-12 15:37:13 -04:00
|
|
|
---
|
|
|
|
title: Combine Multiple Reducers
|
|
|
|
---
|
2019-07-24 00:59:27 -07:00
|
|
|
# Combine Multiple Reducers
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
---
|
|
|
|
## Problem Explanation
|
2018-10-17 14:52:48 +08:00
|
|
|
The goal of this challenge is to combine two reducers into a single reducer which will be passed into the ```Redux.createStore()``` method.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Hints
|
|
|
|
|
2018-10-17 14:52:48 +08:00
|
|
|
### Hint 1
|
|
|
|
Use the method ```Redux.combineReducers()```. Pass an object as an argument.
|
2018-10-12 15:37:13 -04:00
|
|
|
|
2018-10-17 14:52:48 +08:00
|
|
|
### Hint 2
|
|
|
|
The object should have two ```name:value``` pairs. The ```value``` corresponds to the reducer function
|
|
|
|
|
2019-07-24 00:59:27 -07:00
|
|
|
|
|
|
|
---
|
|
|
|
## Solutions
|
|
|
|
|
|
|
|
<details><summary>Solution 1 (Click to Show/Hide)</summary>
|
|
|
|
|
2018-10-17 14:52:48 +08:00
|
|
|
```javascript
|
|
|
|
// define the root reducer here
|
2019-07-24 00:59:27 -07:00
|
|
|
const rootReducer = Redux.combineReducers({
|
|
|
|
count: counterReducer,
|
|
|
|
auth: authReducer
|
|
|
|
});
|
2018-10-17 14:52:48 +08:00
|
|
|
```
|
2019-07-24 00:59:27 -07:00
|
|
|
</details>
|
|
|
|
|