在根屏幕上按返回按钮后重新启动时应用程序卡住
App stuck when relauch after press back button on root screen
我正在使用 React Native 0.57.8
和 Wix React Native Navigation v2.7.1
,在我的根屏幕上,当我按下 phone 的虚拟后退按钮时,应用程序似乎关闭并返回在我的应用程序启动器上。但是,当我重新启动该应用程序时,它会永远卡在黑屏上,直到我终止该应用程序并重新打开它。
我不明白为什么会这样,真的很奇怪。
我在根屏幕上尝试 BackHandler
但没有成功:
this.backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
BackHandler.exitApp();
//return true;
});
谢谢。
我在 App.js 上使用 Navigation.events().registerAppLaunchedListener
的 react-native-navigation 修复了该行为,以便调用 setRoot()
...
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
....
}
},
}
}
});
});
我的修复是:
Navigation.events().registerAppLaunchedListener(() => {
if (Platform.OS === 'android') {
SplashScreen.hide();
}
Navigation.setRoot(myRoot);
}
我正在使用 React Native 0.57.8
和 Wix React Native Navigation v2.7.1
,在我的根屏幕上,当我按下 phone 的虚拟后退按钮时,应用程序似乎关闭并返回在我的应用程序启动器上。但是,当我重新启动该应用程序时,它会永远卡在黑屏上,直到我终止该应用程序并重新打开它。
我不明白为什么会这样,真的很奇怪。
我在根屏幕上尝试 BackHandler
但没有成功:
this.backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
BackHandler.exitApp();
//return true;
});
谢谢。
我在 App.js 上使用 Navigation.events().registerAppLaunchedListener
的 react-native-navigation 修复了该行为,以便调用 setRoot()
...
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
....
}
},
}
}
});
});
我的修复是:
Navigation.events().registerAppLaunchedListener(() => {
if (Platform.OS === 'android') {
SplashScreen.hide();
}
Navigation.setRoot(myRoot);
}