Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vault-development/react-native-svg-uri
Render SVG images in React Native from an URL or static file
https://github.com/vault-development/react-native-svg-uri
Last synced: about 2 months ago
JSON representation
Render SVG images in React Native from an URL or static file
- Host: GitHub
- URL: https://github.com/vault-development/react-native-svg-uri
- Owner: vault-development
- Created: 2016-08-19T21:58:56.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-04-23T21:44:14.000Z (over 2 years ago)
- Last Synced: 2024-09-20T09:10:41.813Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 103 KB
- Stars: 849
- Watchers: 13
- Forks: 335
- Open Issues: 107
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-react-native - react-native-svg-uri - Render SVG images in React Native from an URL or static file(Depends on react-native-svg). ![](https://img.shields.io/github/stars/vault-development/react-native-svg-uri.svg?style=social&label=Star) (Components / Image)
README
# react-native-svg-uri
Render SVG images in React Native from an URL or a static fileThis was tested with RN 0.33 and react-native-svg 4.3.1 (depends on this library)
[react-native-svg](https://github.com/react-native-community/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 casesInstall library from `npm`
```bash
npm install react-native-svg-uri --save
```Link library react-native-svg
```bash
react-native link react-native-svg # not react-native-svg-uri !!!
```## Props
| Prop | Type | Default | Note |
|---|---|---|---|
| `source` | `ImageSource` | | Same kind of `source` prop that `` 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.## Usage
Here's a simple example:
```javascript
import SvgUri from 'react-native-svg-uri';const TestSvgUri = () => (
);
```or a static file
```javascript
```
This will render:
![Component example](./screenshoots/sample.png)
## Testing
1. Make sure you have installed dependencies with `npm i`
2. Run tests with `npm test`