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
Since you already imported the icon library you want, you will not need to import it a second time. All you have to do is go back to the React icons page. Copy another icon that you want and paste it in the curly braces. This is how you can use as many icons as you need from the Font Awesome library.
@expo/vector-icons This library is installed by default on the template project using npx create-expo-app and is part of the expo package. It is built on top of react-native-vector-icons and uses a similar API. It includes popular icon sets that you can browse at icons.
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.
In that case, the final code will look like this:
import MaterialIcon from 'react-native-vector-icons/MaterialIcons;
import Ionicon from 'react-native-vector-icons/Ionicons';
Thank You Fran Rios
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With