Socket
Book a DemoInstallSign in
Socket

@allsquare/react-native-svg-from-uri

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@allsquare/react-native-svg-from-uri

Render an SVG Image from an URL

1.0.4
latest
npmnpm
Version published
Maintainers
1
Created
Source

react-native-svg-from-uri

This is a fork of the unmaintained react-native-svg-uri library, originally written by Matias Cortes.

Render SVG images in React Native from an URL or a static file

This was tested with RN 0.52.0 and react-native-svg 6.3.1, which this library depends on.

Installation

Install library from npm

npm install react-native-svg-from-uri --save

Link the react-native-svg library

react-native link react-native-svg # not react-native-svg-from-uri !

Props

PropTypeDefaultNote
sourceImageSourceSame kind of source prop that <Image /> component has
svgXmlDataStringYou can pass the SVG as String directly
fillColorOverrides all fill attributes of the svg file

Known Bugs

  • [ANDROID] There is a problem with static SVG file on Android, Works OK in debug mode but fails to load the file in release mode. At the moment the only workaround is to pass the svg content in the svgXmlData prop.
  • Not all the svgs can be rendered, if you find problems fill an issue or a PR in order to contemplate all the cases

Usage

Here's a simple example:

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

const TestSvgUri = () => (
  <View style={styles.container}>
    <SvgUri
      width="200"
      height="200"
      source={{
        uri: "http://thenewcode.com/assets/images/thumbnails/homer-simpson.svg"
      }}
    />
  </View>
);

or a static file

<SvgUri width="200" height="200" source={require("./img/homer.svg")} />

This will render:

Component example

Testing

  • Make sure you have installed dependencies with yarn
  • Run tests with yarn test

Keywords

react-native

FAQs

Package last updated on 31 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.