反应导航v5防止后退动作

时间:2020-10-10 12:50:44

标签: javascript react-native navigation expo

我对React Navigation v5有问题。

在我的SplashScreen组件上:

useEffect(() => {
    //I update the database of my app
    //Then... 
    navigation.navigate("AppStack");
    }, []);

这是我在App.tsx上的导航容器

<NavigationContainer>
    <RootStack.Navigator
        screenOptions={{
            headerShown: false,
        }}
        initialRouteName="Splash"
    >
        <RootStack.Screen name={'Splash'} component={SplashScreen}></RootStack.Screen>
        <RootStack.Screen name={'AppStack'} component={DrawerNavigator} />
    </RootStack.Navigator>
</NavigationContainer>;

一切正常,但是问题是,当我在AppStack上时,如果单击导航栏的后退按钮,则我的应用程序将返回Splash堆栈。有防止这种情况的解决方案吗?

谢谢。

0 个答案:

没有答案