1

I'm following the guide from https://reactnavigation.org/docs/bottom-tab-navigator/

import { createBottomTabNavigator } from '@react-navigation/bottom-tabs';
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';

const Tab = createBottomTabNavigator();

function MyTabs() {
  return (
    <Tab.Navigator
      initialRouteName="Feed"
      screenOptions={{
        tabBarActiveTintColor: '#e91e63',
      }}
    >
      <Tab.Screen
        name="Feed"
        component={Feed}
        options={{
          tabBarLabel: 'Home',
          tabBarIcon: ({ color, size }) => 
            <MaterialCommunityIcons name="home" color={color} size={size} />
        }}
      />
      <Tab.Screen
        name="Notifications"
        component={Notifications}
        options={{
          tabBarLabel: 'Updates',
          tabBarIcon: ({ color, size }) =>
            <MaterialCommunityIcons name="bell" color={color} size={size} />
        }}
      />
      
    </Tab.Navigator>
  );
}

Everything works, except it shows the wrong icon. 'home' icon displays sad emoji, and 'bell' icon displays sad emoji with sweat. I tried to change name="" in <MaterialCommunityIcons>icons and it all shows different icons that what the name suggested. The icon that appears are also coloured, so I suspected that it might not be rendering MaterialCommunityIcons at all.

Could someone suggest what might have gone wrong please? Thank you

Vincensiu
  • 125
  • 8

3 Answers3

0

For solving the issue follow these steps

  1. create folder called font inside android/app/src/main/assets
  2. Copy all Fonts inside the node_modules\react-native-vector-icons\Fonts
  3. Paste the same to the above created folder(android/app/src/main/assets/fonts)

Hope it will fix the issue.

0

I was facing the same problem on android.

  1. I just followed the android installation https://github.com/oblador/react-native-vector-icons#android

  2. In my case, I have to ignore this step which should perform in android/app/src/main/java/...MainApplication.java

import com.oblador.vectoricons.VectorIconsPackage;

new VectorIconsPackage()

(it gave me an error)

  1. build the APK again.

And that's it. it works for me.

0

I had similar issues what I did was I added the following to my android/app/build.gradle

apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

Then I ran react-native run-android again and my issue was fixed. Also check out this npm documentation on react-native-vector-icons.