Skip to content

thedarkhorseltd/react-native-cached-network-svg-image

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-cached-network-svg-image

Render SVG images in React Native using a URL or a static file.

SVG's rendered from a url are cached using react native's Async Storage.

Forked from 'react-native-svg-uri'.

Install library from github

"react-native-cached-network-svg-image": "github:sur950/react-native-cached-network-svg-image"

Link library react-native-svg

react-native link react-native-svg # not react-native-cached-network-svg-image !!!

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 false Adds the fill color to the entire svg object
noCache Booleean false will not cache this particular SVG if true

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-cached-network-svg-image';

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published