TabNavigation 中的标题标题为空

IT技术 javascript reactjs react-native react-navigation
2021-05-11 12:02:41

标题标题似乎没有按预期工作。

我已经将 react-native 和所有其他依赖项更新为最新版本,并查看了 react-navigation 文档。此外,我在 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>
        )
    }
}

但我在标题窗格中看到空标题。我想查看来自导航选项的标题文本

空头

1个回答

感谢JinHoSo答案在这里

const bottomTabNavigator = createBottomTabNavigator(...)

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