Reactjs Reducer未使用destructed属性更新状态

Reactjs Reducer未使用destructed属性更新状态,reactjs,react-redux,Reactjs,React Redux,我有以下行动: {type:“SET_GROUP”,GROUP:68,categories:Array(3),year:64} 在我的reducer中,我有以下代码: case "SET_GROUP": const { group } = action; const showStudent = !checkEmptyArray(action); return { ...state, group, showStudent }; 但是,组从

我有以下行动:

{type:“SET_GROUP”,GROUP:68,categories:Array(3),year:64}

在我的reducer中,我有以下代码:

    case "SET_GROUP":
        const { group } = action;

        const showStudent = !checkEmptyArray(action);
        return { ...state, group, showStudent };
但是,
从未添加到状态:

{year: 64, group: 0, student: 0, showStudent: true}
有什么想法吗

减速器:

export function setCredentials(state = initialState, action) {
    switch (action.type) {
        case "SET_YEAR":
            return {
                ...state,
                year: action.year,
                group: 0,
                student: 0
            };
        case "SET_STUDENT":
            return { ...state, student: action.student };
        case "SET_GROUP":
            const { group } = action;

            const showStudent = !checkEmptyArray(action);

            return { ...state, group, showStudent };
        case "CLEAR_CREDENTIALS":
            return initialState;

        default:
            return state;
    }
}
初始状态:

const initialState = {
    year: 0,
    group: 0,
    student: 0,
    showStudent: false
};

如果您没有使用任何保存/加载中间件(这可能是原因所在,在这种情况下,您可以通过在浏览器的developer tools js控制台中执行
localStorage.clear()
命令来解决此问题)
作为对代码的测试,请尝试以下操作:

case "SET_GROUP":
    const showStudent = !checkEmptyArray(action);
    return { 
        ...state, 
        group: action.group, 
        showStudent 
    };

还可以检查您的
“设置年份”
案例,在该案例中,它还可以修改
学生
属性。这种做法,如果减速机变得更大,可能会导致一个混乱的减速机实现(因为它确实执行了一个
“设置年份重置组重置学生”
操作)

你能显示你的初始状态吗?更新的问题如果你在
案例
中记录
,它会打印什么?
没有定义,奇怪的是,你到底是在保存/加载减速器状态吗?