【问题标题】:How to get current routes size of wix/react-native-navigation?如何获取 wix/react-native-navigation 的当前路线大小?
【发布时间】:2019-12-11 11:44:55
【问题描述】:

我正在尝试处理 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”

【问题讨论】:

标签: react-native react-native-navigation wix-react-native-navigation


【解决方案1】:

原来没有这样的方法,两个选项是: 1)自己处理后退按钮(覆盖)或 2)只需将您的自定义逻辑添加到 componentWillUnmount() 并继续使用本机 react-native-navigation

选项 2 对我有用

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-09-20
    • 2021-01-29
    • 1970-01-01
    • 2022-01-16
    • 1970-01-01
    • 2018-12-03
    相关资源
    最近更新 更多