我正在使用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() {
}
关于android - React-router-native AndroidBackButton 没有触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46392091/