Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React native react-navigation tabBarIcon does not display

I'm having a TabNavigator where I want to have icons at each tab together with a label. However, even though I've tried numerous ways in order to get the icon to appear, nothing happens.

// Imports...

const StartScreen =  TabNavigator({
    Home: {
        screen: HomeTab,
        navigationOptions: {
            tabBarLabel: 'Test',
            tabBarIcon:() => <Icon size={ 20 } name={ 'cogs' } color={ 'red' }/>
        }
    },
    Calendar: {
        screen: CalendarTab,
        navigationOptions: {}
    }
});

StartScreen.navigationOptions = {
    title: 'TestApp',
    headerTintColor: '#ffa500',
    showIcon: true
};

export default StartScreen;

And yes, I've tried out using the Icon-component so I know that it works.

Any tips or guidance would be really helpful, thanks!

like image 685
willedanielsson Avatar asked Sep 15 '26 22:09

willedanielsson


1 Answers

This works

const StartScreen =  TabNavigator({
  Home: {
    ...
  },
  Calendar: {
    ...
  },
},  {  
  tabBarOptions: { 
    showIcon: true 
  }, 
});    

EDIT: I just checked and there is no google material icon named cogs. You should double check your naming :)

like image 129
Long Nguyen Avatar answered Sep 18 '26 00:09

Long Nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!