I want to use SVG icons in my React Native project. I'm requiring it like:
var svg = require('../images/Upvote.svg');
But i'm getting this error:
Unable to resolve module ../images/Upvote.svg from /path/to/my/project/js/Component.js: Invalid directory /path/to/my/project/images/Upvote.svg
Am i suppose to add/change something in Xcode project settings?
BTW, everything is fine if i'm using PNG image, no errors..
github.com/react-native-community/react-native-svg - this is an active repo for SVG
SVGs are not supported in React Native at this point. There are a few libraries out there they played with the idea but I don't know that any of them are "production ready"
https://github.com/brentvatne/react-native-svg
https://github.com/aksonov/react-native-svg-elements
I use react native SVG and a small my own component for showing SVG. If the files SVG are too much I think solution with icoMoon is more complex but better. Solution here: Which is the best approach to insert an vector (svg) graph into a react native application
This is my own component that usually use when I use few SVG files in my app.
Then you can use it in this way