I'm trying to import and use my own custom icons in my React Native 0.62.2
app.
I followed the steps outlined here https://github.com/oblador/react-native-vector-icons#custom-fonts but so far the icons are not showing up.
Here are the steps I followed:
- Created my icon set and converted it to fonts on https://icomoon.io
- Downloaded the zip file from
IcoMoon
and placed thettf
file into./src/assets/fonts
folder - I then created
react-native-config.js
file and placed in the root. The code in this file is down below - Under my components folder, I created
CustomIcon.js
-- see code below - I also placed the
selection.json
file that was included in thezip
file I downloaded fromIcoMoon
in the same folder asCustomIcon.js
- I then used the
CustomIcon
as shown below
So here what the codes look like:
The react-native-config.js
file looks like this:
module.exports = {
project: {
ios: {},
android: {},
},
assets: ['./src/assets/fonts/']
};
The CustomIcon.js
file looks like this:
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
import icoMoonConfig from './selection.json';
export default createIconSetFromIcoMoon(icoMoonConfig, 'StreamLine', '../../../assets/fonts/streamline-icon-set-1.ttf');
And here's how I use the icon:
import CustomIcon from '../common_components/fonts/CustomIcon';
<CustomIcon name="home-outline" />
When I run the app in Android Emulator
, I see the missing icon symbol i.e. a box with an X in it.
Any idea what the issue is here?