How to import icons from several files in response to my own vector icons?

If I wanted to use Ionicons and MaterialDesign Icons to edit my own vector icons in the same file, how to import it?

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

(and)

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

in the same file

+5
source share
2 answers

After looking at the original source files, I found out that the icons were exported as

export default iconSet

This way you can use an arbitrary name to import. The last code was

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

Thank you Fran Rios

+9
source

You can use the import rename property on es6:

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

Then you can use IonIcon and MaterialIcon in your code.

+5
source

Source: https://habr.com/ru/post/1266910/


All Articles