Coder Social home page Coder Social logo

react-native-svg-uri's Introduction

react-native-svg-uri

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

This was tested with RN 0.33 and react-native-svg 4.3.1 (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 react-native-svg-uri --save

Link library react-native-svg

react-native link react-native-svg # not 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
fillAll Boolean Adds the fill color to the entire svg object

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-svg-uri's People

Contributors

matc4 avatar henrikra avatar camilo5972 avatar hssrrw avatar kirillpisarev avatar devapro avatar adamski avatar gre avatar iroachie avatar ganmor avatar ruifreitas avatar stefanoeb avatar jpgarcia avatar kevhuang avatar pgom avatar prscx avatar ligaz avatar mathieudutour avatar

Forkers

fakhrodw

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.