tanem / react-svg

:art: A React component that injects SVG into the DOM.

Home Page:https://npm.im/react-svg

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

svg is wrapped two times

michaellill-corefihub opened this issue · comments

The following code

<ReactSVG
                                        src="/website-assets/icons/timer.svg"
                                        wrapper="svg"
                                        className="fill-cfm-green d-flex align-items-center width-20 mr-1"
                                    />

produces something like:

<svg  class="fill-cfm-green d-flex align-items-center width-20 mr-1">
<svg>
<svg>
 the actual svg content...
</svg>
</svg>
</svg>

Expected:

<svg class="fill-cfm-green d-flex align-items-center width-20 mr-1">
 the actual svg content...
</svg>

this code:

<ReactSVG
                                        src="/website-assets/icons/timer.svg"
                                        wrapper="div"
                                        className="fill-cfm-green d-flex align-items-center width-20 mr-1"
                                    />

produces something like:

<div  class="fill-cfm-green d-flex align-items-center width-20 mr-1">
<div>
<svg>
 the actual svg content...
</svg>
</div>
</div>

Expected:

<div  class="fill-cfm-green d-flex align-items-center width-20 mr-1">
<svg>
 the actual svg content...
</svg>
</div>

This is deliberate, please see "Why are there two wrapping elements?" in the FAQ.

@tanem I see. Thank you for the explanation.