title: change value of property in state reducer redux
body: <p>I have a reducer that's state is an array of objects.</p>
  
  <pre><code>state = [{
        id: 1,
        name: 'peter',
        visible: false
      },
      {
        id: 2,
        name: 'alan',
        visible: false
      ];
  </code></pre>
  
  <p>The relevant part of my reducer looks like this.</p>
  
  <p><code>action.id</code> here is <code>1</code></p>
  
  <pre><code>case 'TOGGLE_VIEW':
  
      return state.map(item =&gt; {
  
          if(item.id === action.id) {
  
              item.visible = !item.visible;
  
          }
  
      });
  </code></pre>
  
  <p>The code above returns state to be <code>[null, null]</code></p>
  
  <p>Can anyone explain how I can change the value of property in the state based on an id passed in? </p>