Reactjs Redux状态嵌套在调用操作之后

Reactjs Redux状态嵌套在调用操作之后,reactjs,redux,Reactjs,Redux,我有一个小问题: 我的减速机 const initialObject = { counter: 0, messages: [] }; function message(state = initialObject, action) { switch(action.type) { case actions.ADD_MESSAGE: return state; // do nothing just return the same st

我有一个小问题:

我的减速机

const initialObject = {
    counter: 0,
    messages: []
};

function message(state = initialObject, action) {
    switch(action.type) {

        case actions.ADD_MESSAGE:
            return state; // do nothing just return the same state, expect to equal initialObject
        default:
            return state;
    }
}

const testApp = combineReducers({
   message
});
在我的主要文件中,我有一个行动要求

let store = createStore(reducers);

let unsubscribe = store.subscribe(() =>
    console.log(store.getState())
);

store.dispatch(actions.addMessage("sine text"));
问题是,我在控制台中“subscribe”之后看到的对象


它是嵌套的。。。知道为什么吗?这只发生在动作调用之后

是的,这是因为这条线

const testApp = combineReducers({
   message
});
在ES6中,这个

{ message }
与此相同:

{ message: message }
因此,您的状态是一个对象,带有键。在本例中,它只有一个键:
message

自述文件:

combinereducer()所做的一切就是生成一个函数,该函数使用根据其键选择的状态片调用还原器,并将其结果再次组合到单个对象中。这不是魔法


根据文献,减速机只是组合了多个减速机。。。这与国家无关当然了。。它组合了减速器,对象定义了结构。。就像reducer中的state对象一样,这并不是所有的代码。。。我想。。一定是出了什么事