在根屏幕上按后退按钮后重新启动时应用程序卡住 [英] App stuck when relauch after press back button on root screen
问题描述
我正在使用 React Native 0.57.8
和 Wix React Native Navigation v2.7.1
,当我按下手机的虚拟后退按钮时,在我的根屏幕上,该应用程序似乎关闭并返回到我的应用程序启动器.但是,当我重新启动应用程序时,它会永远卡在黑屏上,直到我杀死应用程序并重新打开它.
I'm using React Native 0.57.8
and Wix React Native Navigation v2.7.1
, and on my root screen when I press the virtual back button of my phone, the app seems to close and goes back on my app launcher. But, when I relauch the app, it get stuck on a black screen forever, until I kill the app and reopen it again.
我不明白为什么会这样,真的很奇怪.
I'm don't understanding why happens that, is really weird.
我在根屏幕上尝试使用 BackHandler
没有成功:
I tried with BackHandler
on the root screen with no success:
this.backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
BackHandler.exitApp();
//return true;
});
谢谢.
推荐答案
我在 App.js 上使用 react-native-navigation 的 Navigation.events().registerAppLaunchedListener
修复了该行为,以便调用 setRoot()
...
I fixed that behaviour with a Navigation.events().registerAppLaunchedListener
of react-native-navigation on App.js, in order to call setRoot()
...
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
sideMenu: {
left: {
component: {
....
}
},
}
}
});
});
这篇关于在根屏幕上按后退按钮后重新启动时应用程序卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!