You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`isLoading` - We set this to `true` when we're trying to check if we already have a token saved in `AsyncStorage`
25
25
-`userToken` - The token for the user. If it's non-null, we assume the user is logged in, otherwise not.
26
26
27
+
So we need to:
28
+
29
+
- Add some logic for restoring token, sign in and sign out
30
+
- Expose methods for sign in and sign out to other components
31
+
32
+
We'll use `React.useReducer` and `React.useContext` in this guide. But if you're using a state management library such as Redux or Mobx, you can use them for this functionality instead.
33
+
34
+
First we'll need to create a context for auth where we can expose necessary methods:
@@ -149,14 +182,10 @@ Another advantage of this approach is that all the screens are still under the s
149
182
We're conditionally defining one screen for each case here. But you could define multiple screens here too. For example, you probably want to defined password reset, signup, etc screens as well when the user isn't signed in. Similarly for your app, you probably have more than one screen. We can use `React.Fragment` - to define multiple screens:
We won't talk about how to implement the text inputs and buttons for the authentication screen, that is outside of the scope of navigation. We'll just fill in some placeholder content.
0 commit comments