React Native error redirecting to Homepage after user login

You cannot navigate to a screen outside the current navigator like that.

It is recommended that you use the authentication flow in the react navigation docs here: https://reactnavigation.org/docs/auth-flow

It uses conditional operations to change the navigator, instead of directly navigating to a screen.

For Example:

isSignedIn ? (
  <>
    <Stack.Screen name="Home" component={HomeScreen} />
    <Stack.Screen name="Profile" component={ProfileScreen} />
    <Stack.Screen name="Settings" component={SettingsScreen} />
  </>
) : (
  <>
    <Stack.Screen name="SignIn" component={SignInScreen} />
    <Stack.Screen name="SignUp" component={SignUpScreen} />
  </>
)

Source: https://reactnavigation.org/docs/auth-flow#how-it-will-work

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top