[英]Swipe transition to go back works, but pressing the back button does not go back
[英]Prevent user from swipe back or using physical back button to go back to splash screen
我無法阻止用戶返回啟動畫面。 以前當我使用 React Navigation 4 時,這是我使用的
const resetAction = StackActions.reset({
index: 0,
actions: [NavigationActions.navigate({ routeName: "HomeScreen" })]
});
navigation.dispatch(resetAction);
但在 React Navigation 5 中,我嘗試了以下代碼但沒有成功:
const resetAction = CommonActions.reset({
index: 0,
actions: [CommonActions.navigate({ name: screenName })]
});
navigation.dispatch(resetAction);
或這個:
navigation.reset({
index: 0,
routes: [{ name: "HomeScreen" }]
});
我還嘗試在Stack.Screen
options
道具或Stack.Navigator
screenOptions
道具中將gestureEnabled
設置為 false,但我仍然可以向右滑動到 go 回到初始屏幕。
有沒有人有任何解決方法? 謝謝你。
網站上有一個身份驗證流程指南,可能有用:這里。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.