I am using React-Native to build an application. I went on FlatIcon to get some custom icons, which I uploaded to IcoMoon and followed the installation steps to properly implement them on react-native
.
The problem is the result I am getting is completely different to what I installed.
This the Icon I am getting on the application:
But I should be getting this result:
CustomIcon.js
import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
import icoMoonConfig from './selection.json';
export default createIconSetFromIcoMoon(icoMoonConfig);
Home.js
import React, { Component } from 'react';
import { ScrollView } from 'react-native';
import CustomIcon from '../helpers/CustomIcon';
export default class Home extends React.Component {
render() {
return (
<ScrollView>
<CustomIcon name="eco-fuel" size={80} />
</ScrollView>
);
}
}
As you can see, it has no colour and the layout is very different. I tried with other icons, but got same results.
I found an alternative to getting my required result. It still doesn't solve the problem of why
react-native-vector-icons
does not show the correct icon layout/colour.Instead of using icons, I downloaded the
.png
from IcoMoon, which was 1-2kb each instead of thesvg
files which were 3-4kb each.I created a CustomIcon.js
As you can see, this would take some time if you had a lot more images.
getting the images Home.js
You can create an Icon component and pass it props to make your own Icons too. But as I am only using
avatar
this is good enough to have a function. But can be greatly improved.