Javascript 当身份验证失败时,React navigation将用户发送到初始路由,而不是登录路由

Javascript 当身份验证失败时,React navigation将用户发送到初始路由,而不是登录路由,javascript,react-native,react-navigation,react-navigation-v5,Javascript,React Native,React Navigation,React Navigation V5,我有一个应用程序,它有一个着陆屏幕作为初始路线。如果用户想要登录,他们必须从登录屏幕导航到登录屏幕。 如果用户按下登录按钮,我会将isauthentication设置为true,显示加载视图。问题在于,如果身份验证失败,例如,当用户输入错误的电子邮件或密码时,加载后会返回到登录屏幕,而不是登录屏幕 身份验证堆栈: const CreateAuthStack = () => ( <AuthStack.Navigator screenOptions={{ head

我有一个应用程序,它有一个
着陆屏幕
作为初始路线。如果用户想要登录,他们必须从
登录屏幕
导航到
登录屏幕
。 如果用户按下登录按钮,我会将
isauthentication
设置为true,显示加载视图。问题在于,如果身份验证失败,例如,当用户输入错误的电子邮件或密码时,加载后会返回到
登录屏幕,而不是
登录屏幕

身份验证堆栈:

const CreateAuthStack = () => (
  <AuthStack.Navigator
    screenOptions={{
      headerStyle: {
        backgroundColor: '#3c74db',
      },
      headerTintColor: '#fff',
      headerTitleStyle: {
        fontWeight: 'bold',
      },
    }}>
    <AuthStack.Screen
      name="Landing"
      component={LandingScreen}
      options={{headerShown: false}}
    />
    <AuthStack.Screen
      name="SignIn"
      component={SignInScreen}
      options={{title: 'Sign In'}}
    />
    <AuthStack.Screen name="Register" component={RegisterScreen} />
  </AuthStack.Navigator>
);
登录功能:

const signIn = (email, password) => {
  setAuthenticating(true);
  axios
    .post(url, data, headers)
    .then(function(response) {
      if (response.status === 200) {
        setAuthenticating(false);
        setUser(email);
        AsyncStorage.setItem('user', email);
      }
    })
    .catch(function(error) {
      if (error.response.status === 404) {
        setAuthenticating(false); // Goes to Landing page instead of staying on signin page
        alert('Email is incorrect');
      } else if (error.response.status === 401) {
        setAuthenticating(false); // Goes to Landing page instead of staying on signin page
        alert('Password is incorrect');
      }
    });
};
const signIn = (email, password) => {
  setAuthenticating(true);
  axios
    .post(url, data, headers)
    .then(function(response) {
      if (response.status === 200) {
        setAuthenticating(false);
        setUser(email);
        AsyncStorage.setItem('user', email);
      }
    })
    .catch(function(error) {
      if (error.response.status === 404) {
        setAuthenticating(false); // Goes to Landing page instead of staying on signin page
        alert('Email is incorrect');
      } else if (error.response.status === 401) {
        setAuthenticating(false); // Goes to Landing page instead of staying on signin page
        alert('Password is incorrect');
      }
    });
};