Coder Social home page Coder Social logo

react-native-svguri's Introduction

@camilo5972/react-native-svg-uri

Render SVG images in React Native from an URL or a static file. This is a Fork of https://github.com/vault-development/react-native-svg-uri

This was tested with RN 0.59 and react-native-svg 9.6.2 (depends on this library) react-native-svg

Not all the svgs can be rendered, if you find problems fill an issue or a PR in order to contemplate all the cases

Install library from npm

npm install @camilo5972/react-native-svg-uri --save

Link library react-native-svg

react-native link react-native-svg # not @camilo5972/react-native-svg-uri !!!

Props

Prop Type Default Note
source ImageSource Same kind of source prop that <Image /> component has
svgXmlData String You can pass the SVG as String directly
fill Color Overrides all fill attributes of the svg file
stroke Color Overrides stroke attribute 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.

Here's a simple example:

import SvgUri from 'react-native-svg-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

  1. Make sure you have installed dependencies with npm i
  2. Run tests with npm test

react-native-svguri's People

Contributors

camilo5972 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.