Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embedding images in SVG in React

Tags:

image

reactjs

svg

I am using SVG inside React, but the amount of SVG tags that ReactJS allows is limited and I don't see a way to embed an <image/> SVG tag inside my JSX.

I've also tried using a fill style on a rect set to a url of an image, but it doesn't work either. Is there a workaround for this?

like image 688
Sergi Mansilla Avatar asked Nov 01 '22 09:11

Sergi Mansilla


1 Answers

SVG Image is now supported in 0.14.

For prior versions, you can use dangerouslySetInnerHTML. For more about that, take a look at this issue:

https://github.com/facebook/react/issues/2069

like image 151
freddyrangel Avatar answered Nov 07 '22 21:11

freddyrangel