vault-development / react-native-svg-uri

Render SVG images in React Native from an URL or static file
849 stars 335 forks source link

Fill getting added to all svg elements, even when fill = none #39

Closed kengorab closed 7 years ago

kengorab commented 7 years ago

I have this up-arrow svg which I got from the material design site:

<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
    <path d="M0 0h24v24H0V0z" fill="none"/>
    <path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" fill="#000000"/>
</svg>

which looks like this:

screen shot 2017-02-24 at 10 34 36 pm

You'll notice that it has two path elements, one with a fill of solid black and one with a fill of "none". When I try to use this svg in the app, I do it like so:

<SvgUri
    width={24}
    height={24}
    fill="#ff00ff"
    source={require('./ic_arrow_upward.svg')}
/>

I'd expect this to produce an icon like this:

screen shot 2017-02-24 at 10 35 20 pm

but instead it ends up looking like this:

screen shot 2017-02-24 at 10 36 00 pm

This is because when applying the fill attribute, the code sets it without first checking if it's set to "none".

henrikra commented 7 years ago

Just remove the other path from the SVG file. End result looks like this:

<svg height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
    <path d="M4 12l1.41 1.41L11 7.83V20h2V7.83l5.58 5.59L20 12l-8-8-8 8z" fill="#000000"/>
</svg>
matc4 commented 7 years ago

fix in the last release!