title: Redux Reducer: Update object in array by key immutably
body: <p>Question: Update the object in <strong>devData</strong> array with <strong>key = 1</strong> this way: -> update <strong>data</strong> and <strong>dateTime</strong></p>
  
  <pre><code>//Redux state:
  {
      info: {
          success: true,
          devData: [
              {
                  key: 1,
                  data: {            &lt;- update this
                      power: 48 ,
                      unit: "kWh"
                  },
                  dateTime: "2019-08-24T18:21:21.000Z"  &lt;- update this
              },
              {
                  key: 2,
                  data: {
                      power: 48,
                      unit: "kWh"
                  },
                  dateTime: "2019-08-24T18:21:01.000Z"
              }
          ]
      }
  }
  </code></pre>
  
  <p>My update method in reducer:</p>
  
  <pre><code>switch (action.type) {
      case 'update':
          return {
              ...state,
              info: {
                  ...state.info,
                  devData: state.info.devData.map(currentValue =&gt; {
                      if (currentValue.key === 1) {
                          currentValue.data = action.payload.data;
                          currentValue.dateTime = action.payload.dateTime;
                      }
                      return currentValue;
                  })
              }
          };
  }
  </code></pre>
  
  <p>My problems:</p>
  
  <ol>
  <li><p>My update method is complicating and ugly, difficult to understand</p></li>
  <li><p>I am not sure, if I am really doing this update in an <strong>immutable</strong> way</p></li>
  <li><p>I think my update method is <strong>computationally expensive</strong>, not efficient</p></li>
  </ol>
  
  <p>I need a method for updating to address the problems above.</p>