title: React doesn't re-render UI
body: <p>The app has a list of entries (orders with tracking numbers and their statuses).</p>
  <p>On click on the update button, it:
  1 - select all undelivered orders,
  2 - set temporary UI (&quot;Loading...&quot; on each undelivered order) by <strong>innerHTML = 'Loading...'</strong>
  3 - check the tracking number
  4 - set new order status</p>
  <p>The problem is:
  If click on update again (2d time) it won't update the UI, it just changes to &quot;Loading...&quot; but doesn't set new status (which is the same).</p>
  <p>I assume the problem is that I change the UI by using innerHTML and the state remains the same. So when the app gets the tracking status, the state doesn't change, and react doesn't re-render the UI.
  But I use this syntaxis <strong>setData({ ...apiDataU })</strong> and this theoretically should re-render the UI anyway (even if the state doesn't change).</p>
  <p>Here is the update function:</p>
  <pre><code>async function updateStatus() {
  // get all undelivered orders
  const ordersNotDel = Array.from(
    document.getElementsByClassName(&quot;status&quot;)
  ).filter((el) =&gt; el.innerText !== &quot;delivered&quot;);
  // set a temp UI while waiting a response from server
  ordersNotDel.forEach((el) =&gt; (el.innerHTML = &quot;Loading...&quot;));
  // preparing request body
  const idsToUpdate = apiData.orders
    .filter((id) =&gt; {
      return id.status !== &quot;delivered&quot;;
    })
    .map((el) =&gt; {
      return {
        _id: el._id,
        tracking_number: el.tracking_number
      };
    });
  
  // send requst to server
  const res = await axios.patch(initialhost + &quot;update&quot;, { idsToUpdate });
  
  // preparing new state
  const apiDataU = { ...apiData };
  apiDataU.orders.forEach((el) =&gt; {
    const elUpd = res.data.filter((elem) =&gt; elem._id === el._id);
  
    if (elUpd.length) {
      el.status = `${elUpd[0].status} upd`;
    }
  });
  
  setData({ ...apiDataU });
  </code></pre>
  <p>}</p>
  <p>Here is the app:
  <a href="https://codesandbox.io/s/react-tracking-6727i?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/react-tracking-6727i?file=/src/App.js</a></p>
  <p>Thanks!</p>