我正在将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>
);

最佳答案

得到它了。

经过一些广泛的文档,阅读并搜寻了互联网上那些甚至有一个非常相似的问题i found this的人。

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

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

@Override
public void onBackPressed() {

}

10-07 19:32
查看更多