3

I want to show SVG icons but the thing I couldn't find the way to show. I tried to use Image and Use components of react-native-svg but they don't work with that. And I tried to do that with native way but it's really hard work to show just SVG icons.

Example code:

<Svg width="80" height="80">
 <Image href={require('./svg/1f604.svg')} />
</Svg>

1 Answer 1

5

Initially, I had the same problem when I had SVG icons in my machine or saved in web URL.

I explored the react-native-svg library, but it does not allow you to include source of SVG icon already created. We can only create new icons using that library.

Later I found react-native-svg-uri which does allow us to use a given path to the icon.

You can use it like this:

import SvgUri from 'react-native-svg-uri';

<SvgUri
    width="200"
    height="200"
    source={{uri:'http://thenewcode.com/assets/images/thumbnails/homer-simpson.svg'}}
/>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.