TabNavigation中的标题标题为空

时间:2018-12-24 15:23:16

标签: javascript reactjs react-native react-navigation

无法弄清楚如何获得预期的结果。我尝试了什么? 我将react-native和所有其他依赖项更新为最新版本。 我查看了反应导航文档,甚至为此在github上创建了一个错误。

我做错什么了吗?我在使用TabNavigation时需要设置标题标题

const RootNavigator = createStackNavigator({
    ...publicScreens,
    Private: {
        screen: PrivateNavigator
    }
}, publicScreensConfig);

const privateScreens = {
    ContactList: {
        screen: ContactList
    },
    Settings: {
        screen: Settings
    }
};

.....

export default createBottomTabNavigator( privateScreens, options );
import React, { Component } from 'react'
import { Text, View } from 'react-native'
import GlobalColors from '../../config/colors';

export default class Settings extends Component {
    static navigationOptions = {
        title: 'Settings',
        headerStyle: {
            backgroundColor: GlobalColors.grayDark,
        },
        headerTintColor: 'white',
        headerTitleStyle: {
            fontWeight: 'bold',
        },
        gesturesEnabled: false,
    }

    render() {
        return (
            <View>
        <Text> Settigs </Text>
      </View>
        )
    }
}

但是我看到标题是空的。 我想查看来自导航选项的标题文本

Empty header

1 个答案:

答案 0 :(得分:0)

感谢JinHoSo在这里

const bottomTabNavigator = createBottomTabNavigator(...)

bottomTabNavigator.navigationOptions = ({navigation, screenProps}) => {
  const childOptions = getActiveChildNavigationOptions(navigation, screenProps)
  return {
    title      : childOptions.title,
    headerLeft : childOptions.headerLeft,
    headerRight: childOptions.headerRight,
  }
}