Sometimes, we want to show SVG file on React Native.
In this article, we’ll look at how to show SVG file on React Native.
How to show SVG file on React Native?
To show SVG file on React Native, we can use the react-native-svg-uri
package.
To install it, we run
npm install react-native-svg-uri --save
Then we link the library with
react-native link react-native-svg
Then we use it by writing
import * as React from "react";
import SvgUri from "react-native-svg-uri";
import testSvg from "./test.svg";
export default () => <SvgUri width="200" height="200" svgXmlData={testSvg} />;
We use the SvgUri
component to render the testSvg
SVG image.
Conclusion
To show SVG file on React Native, we can use the react-native-svg-uri
package.