How to import icons from multiple files in react native vector icons?

react-native-vector-icons not working ios
react-native-vector-icons not showing
react-native-vector-icons custom icons
react-native-vector-icons getimagesource
vector images react-native
node_modules/react-native-vector-icons/fonts fontisto ttf no such file or directory
react native-svg icons
feather icons react-native

If I wanted to use Ionicons and MaterialDesign Icons from react native vector icons in the same file, how should I import it?

import Icon from 'react-native-vector-icons/MaterialIcons';

(and)

import Icon from 'react-native-vector-icons/Ionicons';

in the same file

After going through the original source files I found out that the icons was exported like

export default iconSet

So you could just use any arbitrary name to import. The final code was

import MaterialIcon from 'react-native-vector-icons/MaterialIcons'; import Ionicon from 'react-native-vector-icons/Ionicons';

Thankyou Fran Rios

oblador/react-native-vector-icons, Multiple ways to import: * 1- Importing a specific font as Icon want to have a single file (index.js), and not a file per font like I do. Other files look like this: import Icon from 'react-native-vector-icons/Octicons' export default Icon  Icon.Button Component. 5 To Make a React Native App. 6 Installation of Dependency. 7 Linking of Dependency. 8 CocoaPods Installation. 9 Code to Use Vector Icon in React Native. 9.1 App.js. 10 To Run the React Native App. 11 Output Screenshots.

You can take advantage of using the name you want on each import due type of exporting on react-native-vector-icons:

import IonIcon from 'react-native-vector-icons/Ionicons'
import MaterialIcon from 'react-native-vector-icons/MaterialIcons'

Then you can user IonIcon and MaterialIcon respectively in your code.

react-native-vector-icons, Customizable Icons for React Native with support for NavBar/TabBar/​ToolbarAndroid, image source and full styling. $ npm install react-native-vector-icons --save $ react-native link Keep in mind that if you’ve created your application using create-react-native-app, you’ll need to eject it since we’re using a native dependency. react-native-vector-icons is a set of icon libraries including Entypo, FontAwesome and more. They’re installed natively on each platform assets.

also, you can use it:

// icons.js

import MaterialCommunityIconsI from 'react-native-vector-icons/MaterialCommunityIcons'
import SimpleLineIconsI from 'react-native-vector-icons/SimpleLineIcons'
import MaterialIconsI from 'react-native-vector-icons/MaterialIcons'
import FontAwesomeI from 'react-native-vector-icons/FontAwesome'
import FoundationI from 'react-native-vector-icons/Foundation'
import EvilIconsI from 'react-native-vector-icons/EvilIcons'
import OcticonsI from 'react-native-vector-icons/Octicons'
import IoniconsI from 'react-native-vector-icons/Ionicons'
import FeatherI from 'react-native-vector-icons/Feather'
import EntypoI from 'react-native-vector-icons/Entypo'
import ZocialI from 'react-native-vector-icons/Zocial'
import React from 'react'

export const MaterialCommunityIcons = props => (
    <MaterialCommunityIconsI {...props} />
)
 const SimpleLineIcons = props => <SimpleLineIconsI {...props} />
 const MaterialIcons = props => <MaterialIconsI {...props} />
 const FontAwesome = props => <FontAwesomeI {...props} />
 const Foundation = props => <FoundationI {...props} />
 const EvilIcons = props => <EvilIconsI {...props} />
 const Ionicons = props => <IoniconsI {...props} />
 const Octicons = props => <OcticonsI {...props} />
 const Feather = props => <FeatherI {...props} />
 const Entypo = props => <EntypoI {...props} />
 const Zocial = props => <ZocialI {...props} />

export default  {
    MaterialCommunityIcons,
    SimpleLineIcons,
    SimpleLineIcons,
    MaterialIcons,
    FontAwesome,
    Foundation,
    EvilIcons,
    Ionicons,
    Octicons,
    Feather,
    Entypo,
    Zocial 
}

and you can everytime use it from components:

import Icon  from '../../styles/icons'; 


<Icon.FontAwesome name="user" size={22} style={styles.iconNav} />

React Native Vector Icons, Example contains how to integrate and use Vector Icons in React Native application. For the Vector Icons, we have to import react-native-vector-icons dependency This will make a project structure with an index file named App.js in your  Let’s start by installing react-native-vector-icons and auto-configure the native projects using react-native link: $ npm install react-native-vector-icons --save $ react-native link Keep in mind that if you've created your application using create-react-native-app , you'll need to eject it since we're using a native dependency.

react-native-vector-icons directory, react-native-vector-icons directory.. AntDesign.. stepforward file-markdown.. instagram.. yuque.. slack file-minus.. file-plus.. file-text.. film. Is there a way to import all fonts at once? Something like this : import * as IconSets from "react-native-vector-icons" And in the render method:

Add custom icons to your React Native application, With Fontello/Icomoon and react-native-vector-icons You will receive a ziped file including your new font .ttf and a config.json You can see if it worked by importing an already packaged font-awesome icon in your app:. Installation of React Native Vector Icons. 1. Open your react native project folder in command prompt and execute the below code: npm install react-native-vector-icons --save. npm install react-native-vector-icons --save. After successful execution of the above code, it adds the react-native-vector-icons library. 2.

react-native-vector-icons: Docs & Community, To customize the files being copied, add the following instead: import Icon from 'react-native-vector-icons/FontAwesome'; const myIcon = <Icon Some fonts today use multiple styles, FontAwesome 5 for example, which is  Windows via react-native-windows. Open your solution in Visual Studio, right click the Assets folder in your solution, click Add Existing. Browse to the node_modules\react-native-vector-icons\Fonts folder, select the required font files. Click the Add drop-down and select Add as Link.

Comments
  • can you please tell me after this code how to import Icon ?
  • and from where ? got stuck in missign fonts using this.
  • This did not work for me: I got Unexpected token error in the import line. Any ideas?
  • import EvilIcon from 'react-native-vector-icons/EvilIcons'; works
  • No need for "as" keyword to rename default exports. You give it the whatever name you want. The "as" keyword is used for renaming non default exports, i.e. import {icon as myIcon} from...
  • Totally true, it's more elegant the way you suggested.
  • This is good. allows the good use of components in the application and also a simple solution.
  • You don't need to export MaterialCommunityIcons alone. Really helpful.