小编Dan*_*hez的帖子

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

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)对象是否跟随状态,是否附加到状态?

reducers reactjs redux

1
推荐指数
1
解决办法
41
查看次数

标签 统计

reactjs ×1

reducers ×1

redux ×1