title: Making the login/logout function using AsyncStorage
body: <p>I am making my first React Native app and I am in the process of making the login/logout functions of the app. I am trying to make the app remember the logged in user by using AsyncStorage. here's my code:</p>
  <p>app.js-</p>
  <pre><code>
  import { createAppContainer } from 'react-navigation';
  import { createStackNavigator } from 'react-navigation-stack';
  import Login from './components/login'
  import Signup from './components/signup'
  import Home from './components/home'
  import Profile from './components/profile';
  import AsyncStorage from '@react-native-async-storage/async-storage';
  import React, {useState, useEffect, useCallback, Component} from 'react'
  
  
  
  
  const AppNavigator = createStackNavigator({
    Login: {screen: Login},
    Signup: {screen: Signup},
    Home: {screen: Home},
    Profile: {screen: Profile},
    
  });
  
  const AppNavigator2 = createStackNavigator({
    Home: {screen: Home},
    Login: {screen: Login},
    Signup: {screen: Signup},
    Profile: {screen: Profile},
    
  });
  
  const getData = async () =&gt; {
    try {
        const value = await AsyncStorage.getItem('@userauthkey')
        if (value !== null) {
            return value
        } else {
            return false
        }
    } catch (e) {
        console.log(e)
    }
  }
  
  
  
  const ch = async () =&gt; {
    const c = await getData();
    if (c) {
      
      console.log(c)
      return true 
    } else {
      return false
    }
  };
  
  const check = ch()
  console.log(check)
  
  const App = createAppContainer(  check ? AppNavigator2 : AppNavigator )
  
  
  
  
  export default App;
  </code></pre>
  <p>When I run this the app automaticly goes to &quot;AppNavigator2&quot; regardless of whether the user is logged in or not. I checked the console and &quot;check&quot; does not show anything. How can I solve this issue?</p>