Accessing a part of reducer state from one reducer within another reducer

前端 未结 3 1898
余生分开走
余生分开走 2020-12-03 02:50

I do not know how to access a boolean isLoading flag from reducerForm.js reducer in reducerRegister.js. I have used combineReduc

3条回答
  •  不知归路
    2020-12-03 03:38

    A reducer cannot access another reducer's state, but if you're using redux-thunk you can do so from within an action creator. As an example, you can define an action creator like this:

    export const someAction = () =>
      (dispatch, getState) => {
        const someVal = getState().someReducer.someVal;
        dispatch({ type: types.SOME_ACTION, valFromOtherReducer: someVal });
      };
    

提交回复
热议问题