I'm searching without success information everywhere on the web on how to create an SVG Rect element in React-Native using the react-native-svg feature. What I reached so far is to define some SVG elements in a component and to pass props to the existing SVG Elements like Rect , Circle and so on. But how can I programmatically create a random number of SVG elements and to attach them to the component ? Sadly, it is not specified in the documentation.
-
What do you mean by create an SVG Rect component and Random Number of SVG elements. Can you please elaborateAshwin Mothilal– Ashwin Mothilal2019-02-02 07:48:47 +00:00Commented Feb 2, 2019 at 7:48
-
Exactly what i said..Create for example a Rect element and attach it to the Canvas..in some sorts of For cycles or similiar.Claudio Ferraro– Claudio Ferraro2019-02-02 21:56:43 +00:00Commented Feb 2, 2019 at 21:56
-
Will this repo be useful for you github.com/smooth-code/svgrAshwin Mothilal– Ashwin Mothilal2019-02-03 06:32:51 +00:00Commented Feb 3, 2019 at 6:32
Add a comment
|
1 Answer
I could not find anything on the react-native-svg also.
But this post could be helpfull: How to show SVG file on React Native?.
You have to convert the .svg to JSX like is answered there by Ihor Burlachenko, notice that react-native is deferent from react, in react-native you need to use the react-native-svg module to create the svg JSX component