azl397985856 / fe-interview

宇宙最强的前端面试指南 (https://lucifer.ren/fe-interview)
Apache License 2.0
2.84k stars 260 forks source link

【每日一题】– 2019-09-10 - 实现Redux中的 combineReducers(reducers) #32

Closed azl397985856 closed 4 years ago

azl397985856 commented 5 years ago

combineReducers可以允许你写多个reducer,然后通过它将多个reducer整合到一起,每一个reducer只会对其注册的key进行修改,不会影响其他reducer的state。

例子:


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? ...
  }
}

更多关于combineReducers(reducers) API, 请参考 https://redux.js.org/api/combinereducers

stale[bot] commented 4 years ago

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.