title: Cookie from response doesn't get set in time for navigation within React component
body: <p>I have React component with a method handling authentication.</p>
  <p>Component code</p>
  <pre><code>handleAuthentication(e) {
     e.preventDefault();
     try {
         createAuth();
         this.props.history.push(&quot;/&quot;);
     } catch(e) {
         // error handling
     }
  }
  </code></pre>
  <p>Service calls</p>
  <pre><code>export function createAuth() {
      call(&quot;auth&quot;);
  }
  
  async function call() {
      await Axios.post(&quot;/&quot; + operation, data)
          .catch(r =&gt; // error handling)
          .then(r =&gt; // success handling)
  }
  </code></pre>
  <p>Route logic</p>
  <pre><code>function renderProtectedComponent(Component, props) {
      return Cookies.get(&quot;auth&quot;) ? &lt;Component {...props} /&gt;: &lt;CreateProfileWithRouter /&gt;; 
  }
  </code></pre>
  <p>If I get rid of the <code>this.props.history.push(&quot;/&quot;);</code>, the auth cookie does get populated.</p>
  <p>With <code>this.props.history.push(&quot;/&quot;);</code>, the route logic gets hit, but the auth cookie doesn't get set (quick enough?), on the first navigation attempt, for the route logic to return the <code>&lt;Component {...props} /&gt;</code>. On subsequent attempts, I get <code>&lt;Component {...props} /&gt;</code>.</p>
  <p>I'm wondering what I'm missing to make it so that the auth cookie is set, before the route logic is called.</p>