title: Should I check the AsyncStorage token value against a key in expo react native?
body: <p>I'm new to react native and I'm trying to build a authentication system for my app using the expo cli. I think I understand it generally now, but all of the articles I've read seem to say you should check if a user token exists in AsyncStorage and if it does then take user to the Home/Account page and skip the login, but the token is never compared with a special key or anything. Here is an example of the code it says to return in the articles...</p>
  <pre><code>return (
      &lt;AuthContext.Provider value={authContext}&gt;
        &lt;Stack.Navigator&gt;
          {state.userToken == null ? (
            &lt;Stack.Screen name=&quot;SignIn&quot; component={SignInScreen} /&gt;
          ) : (
            &lt;Stack.Screen name=&quot;Home&quot; component={HomeScreen} /&gt;
          )}
        &lt;/Stack.Navigator&gt;
      &lt;/AuthContext.Provider&gt;
    )
  </code></pre>
  <p>I'm building an app with a monthly membership fee and so do I need to check if the userToken exists and if it does send it to the backend to be validated and then return the user data like in the code below, as this is what I did for the website version that used react, and if the userToken doesn't exist then I just send them to the login page?</p>
  <pre><code>const [isAuthenticated, setIsAuthenticated] = useState(false)
  const [userData, setUserData] = useState(null)
  
  const handleUserToken = () =&gt; {
    // fetch call that sends userToken to be validated and returns {userData, isAuthenticated}
    setSomeState(userData)
  
    return isAuthenticated
  }
  
  state.userToken == setIsAuthenticated(false) ? setIsAuthenticated(handleUserToken())
  
  return (
      &lt;AuthContext.Provider value={authContext}&gt;
        &lt;Stack.Navigator&gt;
          {!state.isAuthenticated ? (
            &lt;Stack.Screen name=&quot;SignIn&quot; component={SignInScreen} /&gt;
          ) : (
            &lt;Stack.Screen name=&quot;Home&quot; component={HomeScreen} /&gt;
          )}
        &lt;/Stack.Navigator&gt;
      &lt;/AuthContext.Provider&gt;
    );
  </code></pre>
  <p>Hope this example makes sense, I would pass the userData down to the components using 'useContext' as well.</p>