Skip to content

Instantly share code, notes, and snippets.

@alexpaul
Created June 21, 2018 16:15
Show Gist options
  • Save alexpaul/e695c031a72cdf7f678019a9c251ac5a to your computer and use it in GitHub Desktop.
Save alexpaul/e695c031a72cdf7f678019a9c251ac5a to your computer and use it in GitHub Desktop.
Setting up tab bar icons using react-navigation and react-native-vector-icons
const TabStack = createBottomTabNavigator(
{
Search: HomeNavStack,
Favorites: FavoritesNavStack,
},
{
navigationOptions: ({ navigation }) => ({
tabBarIcon: ({ focused, tintColor }) => {
const { routeName } = navigation.state;
let iconName;
if (routeName === 'Search') {
iconName = `ios-search${focused ? '' : '-outline'}`;
} else if (routeName === 'Favorites') {
iconName = `ios-heart${focused ? '' : '-outline'}`;
}
return <Ionicons name={iconName} size={25} color={tintColor} />;
},
}),
tabBarOptions: {
activeTintColor: 'tomato',
inactiveTintColor: 'gray',
},
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment