以下减速机的含义是什么?

Jav*_*per 1 reducers reactjs redux

const todos = (state = [], action) => {
  switch (action.type) {
    case 'ADD_TODO':
      return [
        ...state,
        {
          id: action.id,
          text: action.text,
          completed: false
        }
      ]
    case 'TOGGLE_TODO':
      return state.map(todo =>
        todo.id === action.id ? { ...todo, completed: !todo.completed } : todo
      )
    default:
      return state
  }
}
Run Code Online (Sandbox Code Playgroud)

这里.

我试图了解reducer中以下部分的含义:

[
  ...state,
  {
    id: action.id,
    text: action.text,
    completed: false
  }
]
Run Code Online (Sandbox Code Playgroud)

1)......国家的意义是什么?

2)对象是否跟随状态,是否附加到状态?

Kar*_*yan 5

1)......国家的意义是什么?

正在将现有state阵列扩展到新阵列中.

2)对象是否跟随状态,是否附加到状态?

是的,就像你在创建一个普通的数组文字时一样 [{}, {}]