gpt4 book ai didi

react-native - React-Navigation with redux - StackNavigator 中嵌套在 TabNavigator 中的后退按钮触发两个导航器中的后退 Action

转载 作者:行者123 更新时间:2023-12-04 02:25:51 24 4
gpt4 key购买 nike

我有 redux 的 react 导航设置。我的应用程序由一个带有登录和内容屏幕的父 TabBarNavigator 组成。内容屏幕本身就是一个堆栈导航器,其中包含应用程序的主导航。 redux 和导航器的所有其他方面都按预期工作,但 StackNavigator 上的默认后退按钮也会触发它的父 TabBarNavigator 返回。

这是预期的行为吗?我注意到,如果我像这样在 navigationOptions 中定义 headerLeft,它会按预期工作:

static navigationOptions = ({ navigation }) => {
return {
headerLeft: (
<Button transparent onPress={() => { navigation.goBack(); }}><Text>Back</Text></Button>
)
};
};

有谁解释一下是什么原因造成的?有没有办法让默认的 stackNavigator 后退按钮与 redux 一起使用?

最佳答案

也许调度一个 Action 会更好:

    onPress={() => {
navigation.dispatch(NavigationActions.navigate({
routeName: '<screen name here>'
}));
}}

关于react-native - React-Navigation with redux - StackNavigator 中嵌套在 TabNavigator 中的后退按钮触发两个导航器中的后退 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44187074/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com