这是我的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
而不是Explore
或Specials
。我错过了什么?
不得不添加堆栈导航器
const AppStack = createStackNavigator({ App: SpecialsScreen, MenusScreen });
const HomeStack = createStackNavigator({ Home });