rootReducer = combineReducers({potato: potatoReducer, tomato: tomatoReducer})
// This would produce the following state object
{
potato: {
// ... potatoes, and other state managed by the potatoReducer ...
},
tomato: {
// ... tomatoes, and other state managed by the tomatoReducer, maybe some nice sauce? ...
}
}
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
combineReducers可以允许你写多个reducer,然后通过它将多个reducer整合到一起,每一个reducer只会对其注册的key进行修改,不会影响其他reducer的state。
例子:
更多关于combineReducers(reducers) API, 请参考 https://redux.js.org/api/combinereducers