Redux存储未更新数组而是抛出错误状态。列表不可重复

时间:2020-06-06 08:11:47

标签: arrays reactjs redux react-redux redux-saga

下面是我的减速器的代码。每当我尝试更新列表数组时,它都说这是不可迭代的。谁能告诉我我在做什么错误?

initialState = {
   list: [],
   taskAdded: false,
   taskList: ""
}

export const task = (state = initialState, action) => {
    switch (action.type) {
        case types.ADD_TASK:
            return {
                ...state,
                taskList: action.payload,
                taskAdded: true,
                list: [...state.list, action.payload]
            }
        case types.CLEAR_ADD_TASK_STATE:
            return {
                ...state,
                taskList: "",
                taskAdded: false
            }
        default:
            return state

    }
}

0 个答案:

没有答案