How to import a vector icon from directory in React Native?

299 views Asked by At

I would like to know how to import vector icon I've created or from directory in pc by using react native?

1

There are 1 answers

0
FreakyCoder On

I believe that you're trying to use custom font icons. I've built a library to make it easy.

https://github.com/WrathChaos/react-native-custom-icon

Usage:

import MyIcon from "react-native-custom-icon";
import IcomoonConfig from "./assets/icomoon/selection.json";

<MyIcon name="fireworks" color="red" size={50} config={IcomoonConfig} />

You need to install react-native-vector-icons. It's a must dependency. You can put your svg icons to https://icomoon.io/ and get your .ttf font icons from there. It comes with selection.json and icomoon.ttf files. All you need to do is; put these files on your project and look at the above usage example.

If you cannot make it, I wrote a Step By Step Guide