better solution to redux spread operator (#35592)

2 step -> 1 step
This commit is contained in:
Andrew Ma
2019-05-05 12:40:32 -05:00
committed by Tom
parent 7bf2752bd0
commit 586730b69a

View File

@ -12,8 +12,7 @@ const immutableReducer = (state = ['Do not mutate state!'], action) => {
switch(action.type) {
case 'ADD_TO_DO':
// don't mutate state here or the tests will fail
let arr = [...state];
arr.push(action.todo);
let arr = [...state, action.todo];
return arr;
default:
return state;