title: setState to array based on the server response
body: <p>I have the following data structure in my state</p>
  
  <pre><code>this.state = {
  days: [
                  { day: "Monday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Tuesday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Wednesday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Thursday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Friday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Saturday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
                  { day: "Sunday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30, available: false },
              ],
  }
  </code></pre>
  
  <p>I am expecting a response from the server with the same format <code>availabilities</code> array (coming from props).</p>
  
  <p>If the day of the received array matches, I want to overwrite and setState to only those days that get returned. The rest to stay the same. For example if the response is:</p>
  
  <pre><code> { day: "Monday", fromHour: 11, fromMin: 30, toHour: 17, toMin: 30 },
  </code></pre>
  
  <p>I want to setState to the first element of my days array and overwrite fromHour, toHour, fromMin, toMin and set available to true. Here's my below, and the setState where I am currently stuck. Help or suggestions?</p>
  
  <pre><code>setAvailabilities() {
      const { availabilities } = this.props;
      const { days } = this.state;
      const weekday = [];
      const daysAailable = [];
  
  
      for (i = 0; i &lt; availabilities.length; i++) {
          for (j = 0; j &lt; days.length; j++) {
              if (days[j].day === availabilities[i].day) {
                  this.setState({
                      ...this.state.days,
  //stuck here
                  })
              }
          }
      }
  }
  </code></pre>