简体   繁体   中英

Icons not shown in React Navigation DrwaerNavigator

I'm trying to add icons to the below simple React Navigation DrawerNavigator :

  export default createAppContainer(createDrawerNavigator({
  Home: {
    screen: HomeScreen,
    icon: 'home'
  },
  Screen1: {
    screen: Screen1
  },
  Screen2: {
    screen: Screen2
  },
  Screen3: {
    screen: Screen3
  },
}));

The drawer is shown fine but icon isn't.

图标必须是<Image><View>类的组件,而不是字符串。

Make sure you have imported react native vector icons to use icons in your Any Component.

 import Ionicons from 'react-native-vector-icons/Ionicons';
    export default createAppContainer(createDrawerNavigator({
    Home: {
    screen: HomeScreen,
    navigationOptions: {
      drawerIcon: () => <Ionicons name="ios-home" size={30} style={{ width: 24 }} 
    color="#000" />
    }
    },
    Screen1: {
    screen: Screen1
    },
    Screen2: {
    screen: Screen2
    },
      Screen3: {
    screen: Screen3
      },
    }));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM