Skip to content

Commit 7f3c60a

Browse files
committed
spread operator
1 parent a894627 commit 7f3c60a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ function todoReducer(state = todos, action) {
3131
}
3232

3333
function applyAddTodo(state, action) {
34-
const todo = Object.assign({}, action.todo, { completed: false });
35-
return state.concat(todo);
34+
const todo = { ...action.todo, completed: false };
35+
return [ ...state, todo ];
3636
}
3737

3838
function applyToggleTodo(state, action) {
3939
return state.map(todo =>
4040
todo.id === action.todo.id
41-
? Object.assign({}, todo, { completed: !todo.completed })
41+
? { ...todo, completed: !todo.completed }
4242
: todo
4343
);
4444
}

0 commit comments

Comments
 (0)