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

Kamlesh Tilwani picture Kamlesh Tilwani · Nov 23, 2017 · Viewed 13.3k times · Source

Can I import react-native-vector-icons/font-awesome and react-native-vector-icons/Ionicons on same screen? Basically I want to use both font-awesome and Ionicons icons on same screen for different icons?

Example-
import ActionButton from 'react-native-action-button';
import Icon from 'react-native-vector-icons/font-awesome';
import Icon from 'react-native-vector-icons/Ionicons';

Answer

magneticz picture magneticz · Nov 23, 2017

Yes, you can. Because FontAwesome and Ionicons are exported as defaults, you can import them with any name, like so

import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
import IonIcon from 'react-native-vector-icons/Ionicons';

and in your render() method use like

<FontAwesomeIcon name="github" size={16} color="red">
<IonIcon name="github" size={16} color="blue">