I had a little bit of confusion whether to use Spread operator or Object.assign in reducer function to apply changes to the target object.
const toggleTodo = (todo) => {
return Object.assign({}, todo, {
completed: !todo.completed
});
};
Then above mention code is using Object.assign method, and the below one is using spread operator
const toggleTodo = (todo) => {
return {
...todo,
completed: !todo.completed
};
};
Which is the appropriate method in both of these