title: React Navigation 5 Auth Flow
body: <p>In my <code>React Native</code> app, I'm using <code>React Navigation 5</code> and trying to route users to authentication stack if the user is not authenticated i.e. there's no <code>access_token</code> in <code>AsyncStorage</code>.</p>
  
  <p>What I'm confused about is how to get the token from <code>AsyncStorage</code> because it's an asynchronous process. I can't seem to <code>await</code> the call in my <code>App</code> component i.e. it gives me an error if I try and if I don't <code>await</code> it, then I get a <code>promise</code>.</p>
  
  <p>How do I implement this using <code>React Navigation 5</code>?</p>
  
  <p>Here's my <code>App</code> component:</p>
  
  <pre><code>const App = () =&gt; {
  
    const authenticatedUser = AsyncStorage.getItem("access_token");
    return (
      &lt;Provider store={store}&gt;
        &lt;NavigationContainer&gt;
          {
            authenticatedUser !== null || typeof authenticatedUser !== "undefined"
            ? &lt;RootNavigator /&gt;
            : &lt;AuthNavigator /&gt;
          }
        &lt;/NavigationContainer&gt;
      &lt;/Provider&gt;
    );
  };
  
  export default App;
  </code></pre>