Answers for "use icon in tab bar react native"

0

use icon in tab bar react native

const screenOptions = (route, color) => {
  let iconName;

  switch (route.name) {
    case 'Home':
      iconName = 'home';
      break;
    case 'Browse':
      iconName = 'appstore-o';
      break;
    case 'Library':
      iconName = 'folder1';
      break;
    default:
      break;
  }

  return <Icon name={iconName} color={color} size={24} />;
};

const TabNavigator = () => {
  return (
    <Tab.Navigator
      screenOptions={({route}) => ({
        tabBarIcon: ({color}) => screenOptions(route, color),
      })}>
      {/* rest remains same */}
    </Tab.Navigator>
  );
};
Posted by: Guest on October-10-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language