Accessing other parts of the state, when using combined reducers

前端 未结 4 653
情歌与酒
情歌与酒 2020-12-29 05:42

NB: This is a question, very similar to Redux; accessing other parts... but it has nothing to do with Router :( thus cannot be solved s

4条回答
  •  鱼传尺愫
    2020-12-29 06:09

    You can try to use:

    redux-named-reducers

    Which allows you to get state anywhere in your code like so:

    const localState1 = getState(reducerA.state1)
    const localState2 = getState(reducerB.state2)
    

    Works with combineReducers such that each reducer only handles local state but can access external state if needed.

提交回复
热议问题