简体   繁体   English

如何获取 wix/react-native-navigation 的当前路线大小?

[英]How to get current routes size of wix/react-native-navigation?

I'm trying to handle the back button on android since my React Native app has custom logic on the back button pressed for the root screen...Is there any method like Navigation.getCurrentRoutes() in order to do something like this:我正在尝试处理 android 上的后退按钮,因为我的 React Native 应用程序在为根屏幕按下的后退按钮上具有自定义逻辑......是否有任何方法如Navigation.getCurrentRoutes()来执行以下操作:

handleBackButton = () => { 
if(Navigation.getCurrentRoutes().size()>1) {
return true; // addEventListener listens for the native hardware back button press and will ignore it
} 
... customLogic
return false; //  will execute the native back press (and exit the app) 
} 

"react-native-navigation": "3.0.0-alpha.2" “反应原生导航”:“3.0.0-alpha.2”

It turns out that there is not such a method and the two options are: 1) Handle back buttons on your own (overriding) or 2) just add your custom logic into componentWillUnmount() and continue using the native react-native-navigation事实证明,没有这样的方法,两个选项是:1)自己处理后退按钮(覆盖)或 2)只需将自定义逻辑添加到 componentWillUnmount() 并继续使用本机 react-native-navigation

options 2 worked for me选项 2 对我有用

reference: https://github.com/wix/react-native-navigation/pull/4226#issuecomment-433683885 https://github.com/wix/react-native-navigation/issues/4231参考: https : //github.com/wix/react-native-navigation/pull/4226#issuecomment-433683885 https://github.com/wix/react-native-navigation/issues/4231

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM