title: React redux - issues adding multiple items to an array in state tree object
body: <p>I am looking at redux and adding names to an array. The code below works (kind of!).</p>
  
  <p>I have a few issues.</p>
  
  <ol>
  <li><p>I know that it is advised to create a new state tree object each time the state is passed through the reducer, however I thought it should still work even if I change the state object passed in.
  In my code below the <code>console.log(store.getState());</code> works if I use <code>var newArr = state.names.concat(action.name);</code> but not if I use <code>state.names.push(action.name);</code></p></li>
  <li><p>If I add another <code>store.dispatch(action)</code> the code doesn't work.</p>
  
  <p><code>store.dispatch({type: 'ADD_NAME',name: 'PhantomTwo'});</code></p></li>
  </ol>
  
  <p>Can anyone explain why this is so?</p>
  
  <ol start="3">
  <li>Finally, do I need to return state again outside the switch statement?</li>
  </ol>
  
  <p>Here is the code I currently have below.</p>
  
  <pre><code>const initialState = {
      names: []
  }
  
  function namesApp(state = initialState, action) {
      switch(action.type) {
          case 'ADD_NAME':
              var newArr = state.names.concat(action.name);
              return newArr;
          default: 
              return state;
      }
  }
  
  let store = createStore(namesApp);
  
  store.dispatch({
      type: 'ADD_NAME',
      name: 'Phantom'
  });
  
  console.log(store.getState()); //returns `["Phantom"]`
  </code></pre>