为什么我的 Reducer 没有收到我的 Actions? (使用 React 和 Redux)

Why is my Reducer not receiving my Actions? (Using React & Redux)

这些是我目前的动作创作者,他们 运行 正常并且 return 动作一如既往。我已经测试了一些日志记录,它在这里工作:

export function stateToEntry() {
    return { type: types.STATE_TO_ENTRY, formState: 'entry-mode'};
}

export function stateToEdit() {
    return { type: types.STATE_TO_EDIT, formState: 'edit-mode'};
}

export function stateToDelete() {
    return { type: types.STATE_TO_DELETE, formState: 'delete-mode'};
}

这是我当前的减速器,它没有接收到我的操作。我这里测试过,貌似连控制台都登录不上:

import * as types from '../actions/actionTypes';

export default function formStateReducer(state = [], action) {
    switch(action.type) {
        case types.STATE_TO_ENTRY:
            console.log('entry-mode');
            return {formState: action.formState};
        case types.STATE_TO_EDIT:
            //console.log('edit-mode');
            return {formState: action.formState};
        case types.STATE_TO_DELETE:
            //console.log('delete-mode');
            return {formState: action.formState};
        default:
            return state;
    }
}

这是我的组合减速器。 locations reducer 工作正常,但我的 formState 为空,因此它在商店内正确链接。 :

const rootReducer = combineReducers({
    locations,
    formStates
});


export default rootReducer;

我可能错过了什么?

来自文档:bindActionCreators ... 将值为 action creators 的对象转换为具有相同键的对象,但将每个 action creator 包装到一个调度调用中,以便可以直接调用它们.

所以,你用错了,试试这个:

let foo = {
    location: bindActionCreators(locationActions, dispatch),
    form: bindActionCreators(formActions, dispatch)
}
// later in your code -- will dispatch that action automatically
foo.location.someActionFromLocationActionsObject()