react-nativereact-navigation-v5react-navigation-bottom-tabreact-native-vector-icons

React Native Vector Icons won't show in Bottom Tab Navigation in Android


the icon shows in a screen/page, but won't show in the bottom navigation. Solutions that I've tried:

screenshot bottom nav bar

screenshot setting screen

It does appear in screen/page as shown in above screenshot, but won't show in the bottom navigation.

NOTE: I've tested both in emulator and real android device, but still got same result!

Code for the bottom tab

import React from 'react'
import { StyleSheet, Text, View } from 'react-native'
import Ionicons from 'react-native-vector-icons/Ionicons'
import { createBottomTabNavigator } from '@react-navigation/bottom-tabs'
import ProductNavigation from './ProductNavigation'
import SettingScreen from '../screen/SettingScreen'



const BottomTab = createBottomTabNavigator();

const BottomTabNav = () => {
return (
    <BottomTab.Navigator>
        <BottomTab.Screen 
        name="Home" 
        component={ProductNavigation} 
        options={{
            tabBarLabel: "Home",
            tabBarIcon:({color, size}) => {
                <Ionicons name="home-outline" color={color} size={size} />
            }}} />

        <BottomTab.Screen 
        name="Settings" 
        component={SettingScreen}
        options={{
            tabBarLabel: "Settings",
            tabBarIcon: ({color, size}) => {
                <Ionicons name="settings-outline" color={color} size={size} 
    />
            
        }}} />
    </BottomTab.Navigator>
   )
  }

 export default BottomTabNav

 const styles = StyleSheet.create({})

Also can you help why does the bottom tab goes to the next page?? where should I edit the code, thanks in advance. Below is the Screenshot: enter image description here


Solution

  • The issue is very simple actually, you are not returning anything from the function,

        tabBarIcon: ({color, size}) => {
    //nothing returned here
                        <Ionicons name="settings-outline" color={color} size={size} 
            />
    

    You have to do this, either use brackets like below or use the return statement to your code.

    tabBarIcon: ({color, size}) => (
                    <Ionicons name="settings-outline" color={color} size={size} 
        />)