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

时间:2018-08-29 01:47:58

标签: react-native react-navigation

这是我的navigation.js:

<p>

因此,该应用启动了,您会看到if屏幕:

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 },
});

从那里单击“我同意”使用条款,并发送到Home屏幕:

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。我想念什么?

1 个答案:

答案 0 :(得分:0)

必须添加堆栈导航器

const AppStack = createStackNavigator({ App: SpecialsScreen, MenusScreen });
const HomeStack = createStackNavigator({ Home });