javascript - TabNavigator 如何使用 tabBarComponent?标签栏不显示

标签 javascript react-native react-navigation tabnavigator

我正在尝试制作我自己的自定义标签栏,看来 tabBarComponent 是通过设置为我自己的组件来实现的方法。使用以下代码,我的标签栏不会显示。

const TabNav = TabNavigator({
  LaunchScreen: {
      screen: PrimaryNav,
      navigationOptions: {
        tabBarLabel:'Find',
        tabBarIcon: ({ tintColor }) => (
          <Icon name='search' size={20} color='white' />
        ),
      },
   },
}, {
  navigationOptions: {
    headerTintColor: 'grey'
  },
  tabBarComponent: FooterTabs,
  tabBarPosition: 'bottom',
  swipeEnabled:false,
  animationEnabled:false,
  lazy:true,
  tabBarOptions: {
      showIcon:true,
      showLabel:false,
      style: {
          backgroundColor: 'black'
      }
  }
});

在 FooterTabs.js 中:

export default class FooterTabs extends Component {
  render () {
    return (
      <View style={styles.container}>
        <Text>FooterTabs Component</Text>
      </View>
    )
  }
}

我错过了什么?

最佳答案

    const TabNav = TabNavigator({
      ......,
     tabBarComponent: props => (
     <FooterTabs{...props} />
     ),
     tabBarPosition: 'bottom',
     ........

    });

试试吧。附上您的页脚标签,即 <FooterTabs />不是 FooterTabs

关于javascript - TabNavigator 如何使用 tabBarComponent?标签栏不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45099753/

相关文章:

react-native - react native 操作栏和 react native 菜单

react-native - 默认情况下,react-navigation v3 中标题后退按钮不起作用

javascript - 带有 IE 的 SharePoint

javascript - 自动聚焦列表项中的表单输入

javascript - 在 axios 调用中,事件永远不会在 VueJS 中发出

javascript - 使用可定制的 props 来响应 Native FlatList(良好实践)

css - 如何在 TouchableOpacity 中插入文本和图像?

reactjs - 如何使用 React Navigation V5 在我的抽屉中添加注销按钮

android - React Navigation(使用 Expo)- MainActivity.java 文件的位置?

javascript - 使用 angularJS 服务将 `setInterval` 转换为 AngularJS