在redux文档(http://redux.js.org/docs/basics/ExampleTodoList.html)的reducers / todos.js部分中:
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
}
}
state
这是一个对象,我认为' ...
'运算符不能应用于对象但只能应用于数组,我的理解是否正确?