Open laramlewis opened 9 years ago
not sure this will be easy to support. The reason this doesn't work, is that the SVG gets parsed as JSX, which doesn't support style tags.
However, it would work if instead of having this:
<style>.st0{fill:#777677;}</style><path class="st0" d="M-11.3 22l-.7-.7 4.6-4.6L-12 12l.7-.7 5.4 5.4z"/>
You'd have this
<path fill='#777677' d="M-11.3 22l-.7-.7 4.6-4.6L-12 12l.7-.7 5.4 5.4z"/>
So essentially, instead of using style tags, use inline styles. Not sure this helps, i.e. I don't know whether your design team can easily produce svgs like this
Thank you for your reply. I will let our design team know.
On a related note, once you move the styles inline, you need to remove the class
attribute if you want to avoid this console warning: Warning: Unknown DOM property class. Did you mean className?
I definitely ran into a similar issue when I used style
instead of className
. I think partially because I'm used to developing on React Native. Error message wasn't helpful at all.
I am using react-svg-icons and started encountering the error below when I added SVG files that contain style elements:
E.g.
However, if I change the SVG to put the style in-line, the error goes away:
E.g.
Error:
These SVG files are coming from our design team and I assume are valid SVG, but I don't know enough about SVG to be certain. Is it possible to have react-svg-icons support SVG files like these that contain style elements?