일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- concept
- node.js
- REACT
- 삶
- tailwindcss
- graphQL
- solidity
- useState
- typeScript
- error
- blockchain
- HTML
- bitcoin
- JavaScript
- hardhat
- Interface
- Props
- CLASS
- Ethereum
- evm
- built in object
- middleware
- Redux
- API
- web
- SSR
- CSS
- nextJS
- 기준
- express.js
- Today
- Total
ReasonJun
Redux: CombineReducers 본문
CombineReducers is a Redux helper function that takes an object of reducers as input and returns a single reducer that combines the functionality of all the reducers in the object. This is useful when your application has a complex state that is managed by multiple reducers.
The syntax for using CombineReducers is as follows:
const rootReducer = combineReducers({
counter: counterReducer,
todos: todosReducer,
});
In this example, the counterReducer and todosReducer are two separate reducers that manage the counter and todos state properties, respectively. The combineReducers function combines these two reducers into a single reducer called rootReducer.
The rootReducer is then passed to the createStore function to create the Redux store for the application.
Here are some of the benefits of using CombineReducers:
- It makes it easier to manage complex state.
- It helps to improve code readability and maintainability.
- It reduces the number of reducers that need to be defined.
Here are some of the things to keep in mind when using CombineReducers:
- The keys of the object passed to CombineReducers must be the names of the state properties that the reducers manage.
- The reducers passed to CombineReducers must be pure functions.
- CombineReducers does not check for conflicts between the reducers. It is up to the developer to ensure that the reducers do not conflict with each other.
'Frontend > Redux' 카테고리의 다른 글
Redux: toolkit (0) | 2023.08.19 |
---|---|
Redux : middleware / Thunk (0) | 2023.08.19 |
Redux : Provider / useSelector / useDispatch (0) | 2023.08.19 |
Redux: strict unidirectional data flow (0) | 2023.08.19 |
Redux : What is Redux (0) | 2023.08.19 |