title: Page is loaded before API Call on React
body: <p>I'm new on React, I'm trying to create a ProtectedRoute which only load if i receive true from a API Call, otherwise will be redirected to a different page.
  The issue is that the page load first and then the API is called.</p>
  <ol>
  <li>The Blue part is the call to the API to obtain the &quot;hasAccess&quot; variable which can be true or false</li>
  <li>the details of the routes I have and the ProtectedRoute one.</li>
  <li>When I set the values of auth manually to True or false it works as expected but when I set the value of auth={hasAccess} then it always return false because the API is called after the page is loaded.
  <a href="https://i.stack.imgur.com/mw922.png" rel="nofollow noreferrer">code snippet screenshot</a></li>
  </ol>