无法在ngrx存储区的todolistReducer中读取未定义的属性'concat'

时间:2019-07-25 09:07:28

标签: angular7 ngrx-store

我正在学习如何在angular 7中使用ngrx store。当我调度一个动作来存储细节时,它会引发错误

Cannot read property 'concat' of undefined at todolistReducer.

在减速器文件中。请帮助

// todolist.reducer.ts

import { Todo } from '../../todo';
import { Action } from '@ngrx/store';

import * as ToDoListAction from '../actions/todolist.action';
const initialState = {
    todoList: Todo['']
};
export function todolistReducer(state = initialState, action:                             ToDoListAction.AddTodoList) {
    switch (action.type) {
        case ToDoListAction.ADD_TODOLIST:
            return {
                ...state,
                todoList: [...state.todoList, action.payload]
            };
       default:
            return state;
    }

}

// component.ts

this.storeObj.dispatch(new todoListActions.AddTodoList(obj));

0 个答案:

没有答案