【问题标题】:react-router-native AndroidBackButton is not firingreact-router-native AndroidBackButton 没有触发
【发布时间】:2017-09-24 16:08:15
【问题描述】:

我正在使用 react-router-native 和弹出的 CRNA 应用程序。我已将<AndroidBackButton> 组件添加到我的<NativeRouter>,因为它显示in the docs,但它似乎没有触发。

有什么方法可以调试它以查看它是否没有正确获取值?我在我的应用程序中使用<Redirect><Link> 进行路由,因此应该有可供RR 使用的历史记录项。

欢迎任何想法或想法。

export default props => (
  <NativeRouter>
    <AndroidBackButton>
      <Switch>
        <Route exact path="/" component={Flash} />
        <Route path="/will_not_work" render={routeProps => <WillNotWork {...props} {...routeProps} />} />

        <View style={styles.container}>
          <Switch>
            <Route path="/menu" render={routeProps => <Menu {...props} {...routeProps} />} />
            <Route path="/car_compatibility" render={routeProps => <CarCompatibilityChecker {...props} {...routeProps} />} />
            <Route path="/how_it_works" render={routeProps => <HowItWorks {...props} {...routeProps} />} />
            <Route path="/app_demo" render={routeProps => <AppDemo {...props} {...routeProps} />} />
          </Switch>
        </View>
      </Switch>
    </AndroidBackButton>
  </NativeRouter>
);

【问题讨论】:

    标签: android react-native react-router react-native-android react-router-native


    【解决方案1】:

    明白了。

    在阅读大量文档并在互联网上搜索任何有类似问题的人之后,i found this

    当我查看我的MainActivity.java 文件时,我发现我有一个空的onBackPressed 函数。我删除了它,瞧!我的后退按钮按预期工作。

    这是从MainActivity.java中删除的代码:

    @Override 
    public void onBackPressed() { 
    
    } 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-26
      • 1970-01-01
      • 1970-01-01
      • 2019-11-06
      • 2019-01-20
      • 2021-09-27
      相关资源
      最近更新 更多