Redux: Use the Spread Operator on Arrays

I 'm unable to figure out why my code is not working, please help ,

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
    return [... state, action.todo];
      return state;

const addToDo = (todo) => {
  return {
    type: 'ADD_TO_DO',
    todo: todo

const store = Redux.createStore(immutableReducer);

1 Like

You should not have a space between the spread operator and the array named state.

1 Like

i think you have a space after the three dots? (…state) not (… state) The dots should not have a space after them.

Thank you .
How you guys can find out these errors not us? are you using any software ?

yup. the ‘software’ is our experience… :slight_smile:
When you make mistakes over and over, you learn.