如何在其他屏幕的反应导航中导入底部导航器

时间:2019-05-08 05:12:43

标签: react-native

我已经使用react-navigation创建了一个底部导航器。如何将其用于底部导航器中未包含的其他屏幕?

const Stack = createStackNavigator({
intro: {
    screen: IntroSlides
},
dashboard: {
    screen: createBottomTabNavigator({
        inbox: {
            screen: Inbox,
            navigationOptions: ({ navigation }) => ({
                tabBarIcon: () => (
                    <Image resizeMode={'contain'} style={styles.icon} source={require('./src/assets/MyProfileIcon.png')} />
                ),
                title: 'Profile',
            }),
        },

        favourite: {
            screen: Favourite,
            navigationOptions: ({ navigation }) => ({
                tabBarIcon: () => (
                    <Image resizeMode={'contain'} style={styles.icon} source={require('./src/assets/FavouriteIcon.png')} />
                ),
                title: 'Favourite',
            }),

1 个答案:

答案 0 :(得分:0)

将其他项目/屏幕放置在堆栈导航器中:

const Bottom = createBottomTabNavigator({
    item1: {screen: Screen1},
    item2: {screen: Screen2},
    },{
        initialRouteName: "item1",
    }
)

export default createStackNavigator({
    tabs: Bottom,
    item3: Screen3, // your other screen
})

,如果要从item3屏幕隐藏stacknavigator,可以在组件中使用它:

static navigationOptions = ({ navigation, screenProps }) => ({
    header: null
});