反应导航中的`goBack`不会回来

问题描述 投票:0回答:1

这是我的navigation.js:

export const BottomTabs = createBottomTabNavigator({
    'Specials': {
        screen:SpecialsScreen
    },
    'Menus': {
        screen:MenusScreen
    },
});

export const Drawer = DrawerNavigator({
    Home: { screen: Home, navigationOptions: {drawerLabel:() => null} },
    Explore: { screen: BottomTabs },
    'Support & Contact': { screen: ContactScreen },
    Settings: { screen: Settings, navigationOptions: {drawerLabel:() => null} },
    TOU: { screen: TOU, navigationOptions: {drawerLabel:() => 'Terms of Use'} },
    Privacy: { screen: Privacy, navigationOptions: {drawerLabel:() => 'Privacy Policy'} },
    Disclaimer: { screen: Disclaimer },
});

所以应用程序启动,你得到theHome屏幕:

App.js
render(){
    return(<Provider store={store}><Drawer /></Provider>)
}

从那里你点击“我同意”使用条款并被发送到Explore屏幕:

HomeScreen.js
<TouchableOpacity onPress={() => {
    this.props.navigation.navigate('Specials');
}}>

Specials我点击汉堡图标切换我的抽屉,然后去Support & Contact,有一个后退按钮,我想带我回到上一个屏幕:

ContactScreen.js
<TouchableOpacity onPress={() => {
    this.props.navigation.goBack();
}}>

但这就像我想象的那样带我到Home而不是ExploreSpecials。我错过了什么?

react-native react-navigation
1个回答
0
投票

不得不添加堆栈导航器

const AppStack = createStackNavigator({ App: SpecialsScreen, MenusScreen });
const HomeStack = createStackNavigator({ Home });
© www.soinside.com 2019 - 2024. All rights reserved.