title: Firebase Persisting Auth with Stack Navigator
body: <p>Attempting to let Firebase persist authentication within the app.js of React Native by doing the following:</p>
  <p>There is a sign in page that envokes auth() sign in via Firebase, which works fine, and redirects to the home page via navigation.replace(&quot;Home&quot;); however, once the app is closed and relaunched on the emulator, it redirects back to sign in.</p>
  <p>This is seemingly what the App.js looks like, I assume that the AuthStateChanged would be prevalent as depicted below, however, user is not accessed in App.js as it is established in SignIn.js, when the Firebase credentials are sent, but I assume it would be similar to this layout?</p>
  <pre><code>const App = () =&gt; {
  
    var initialRoute = null
  
    React.useEffect(() =&gt; {
          const unsubscribe = auth().onAuthStateChanged(user =&gt; {
              if(user) {
                  initialRoute = &quot;Home&quot;
              }
              else {
                initialRoute = &quot;SignIn&quot;
              }
          })
  
          return unsubscribe
      }, []);
  
    return (
      &lt;NavigationContainer&gt;
        &lt;Stack.Navigator
          screenOptions={{
            headerShown: false,
          }}
          initialRouteName={initialRoute}
        &gt;
  </code></pre>
  <p>The reason it needs to affect the initial route, and not just redirect anyone who reopens to the home page, is because after registration, there are extra steps included that adjust the database,   such as location mapping and etc., therefore, the redirection has to occur within the initial route.</p>
  <p>Thanks for your assistance.</p>