authentication – React native: How to force sign in when button pressed

Suppose you have a 2 screens:

  1. a SignIn screen where the user signs in to their account, and
  2. a Home screen where the user can perform some actions by pressing buttons.

We want the user to see the Home screen whether they’re signed in or not, but when they press a button on the Home screen, we require that they must be signed in for that button to have affect. We therefore want to direct them to the SignIn screen when they press the button if they are not already signed in.

I’ve read about React Navigation Authentication flows but they only explain how to either show the SignIn screen or the Home screen. I like how in their example, they pop all the authentication screens from the stack if the user is signed in, and would like to do something similar for this case.

What’s the best way of doing this?

Read more here: Source link