0

In the reducers/todos.js section of redux document (http://redux.js.org/docs/basics/ExampleTodoList.html):

const todo = (state, action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return {
        id: action.id,
        text: action.text,
        completed: false
      }
    case 'TOGGLE_TODO':
      if (state.id !== action.id) {
        return state
      }

      return {
        ...state,
        completed: !state.completed
      }
    default:
      return state
  }
}

the state here is an object, I think the '...' operator can't be applied on object but only on array, is my understanding correct?

Benny
  • 8,547
  • 9
  • 60
  • 93

0 Answers0