React Native SVG Elements
Use React Native to draw SVG Elements.
Supported SVG Elements
- Path
- Use
- Defs
- Mask
- LinearGradient
- G
Example
Draw Sine function
'use strict'; { var path = `M `; var x y; for var i = 0; i <= 10; i += 05 x = i * 50; y = Math * 100 + 120; path = path + ` L ` return path;} var React = ;var StyleSheet Text View = React; var Svg Path = ;var TimerMixin = ; var Wave = React;
Getting started
npm install react-native-svg-elements --save
- In XCode, in the project navigator, right click
Libraries
➜Add Files to [your project's name]
- add
./node_modules/react-native-svg-elements/RCTSvg.xcodeproj
- In the XCode project navigator, select your project, select the
Build Phases
tab and in theLink Binary With Libraries
section add libRCTSvg.a var Svg = require('react-native-svg-elements'); var Path = Svg.Path
Todo
- Support Rect
- Support onPress and other events
Credits
Thanks to @GenerallyHelpfulSoftware for SVG rendering library (https://github.com/GenerallyHelpfulSoftware/SVGgh). Thanks to @brentvatne for React Native SVG library (https://github.com/brentvatne/react-native-svg) examples given from.