Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't load static SVG #20

Closed
igongora opened this issue Nov 25, 2016 · 12 comments
Closed

Can't load static SVG #20

igongora opened this issue Nov 25, 2016 · 12 comments

Comments

@igongora
Copy link

I've installed this component and tried to use it with my own static file (https://gist.github.com/igongora/686f13f3a9db38f47d47249db1cf1c1a), but for some reason it doesn't work. I get 'TypeError: invalid svg' from the console

Great component right here, congrats!

@oanogin
Copy link

oanogin commented Nov 30, 2016

@igongora just try to remove xml tag, style block and id attribute
u will get something like this:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 333 168" style="enable-background:new 0 0 333 168;" xml:space="preserve"> <g> <path class="st0" d="M254.1,6.8c15.2,0,28.8,9.6,33.8,24l1.4,3.9c0.5,1.5,2,2.4,3.6,2.3l4.1-0.3c3.2-0.3,4.5,0.1,7.5,1 c5.2,1.5,9.8,4.8,12.5,9.5c4.4,7.7,3.4,17.1-2.5,25.6c-1,1.5-2.4,2.8-4,3.7l-44.8,29.7c-0.7,0.5-1.6-0.2-1.4-1l2.9-10.2 c1.1-3.9,0.5-8.1-1.9-11.4c-2.4-3.2-6.1-5.1-10.1-5.1h-50.7c-5.7,0-11-3.1-13.8-8c-1.8-3.1-4.1-9.5,0.6-17.8c0.6-1.1,1.5-2,2.6-2.8 c3.5-2.3,7.1-3.5,10.6-3.5c1.1,0,2.2,0.1,3.3,0.4l5.7,1.2c2.1,0.4,4.1-1,4.4-3.2l0.6-5.8C220.3,20.7,235.6,6.8,254.1,6.8"/> <g>...

@chandlervdw
Copy link

I am getting this same error. No extra tags.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="16.8 82.7 926.9 404.1"><path fill="#FFF" d="M139 230.5c15.2 0 1 ...

@oanogin
Copy link

oanogin commented Dec 2, 2016

@chandlervdw because u need to pass other extra tags such as
"version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="16.8 82.7 926.9 404.1 style="enable-background:new 0 0 333 168;" xml:space="preserve"

@igongora
Copy link
Author

igongora commented Dec 7, 2016

I could made the SVG render adding "width" and "height" attributes, but still no color

@oanogin
Copy link

oanogin commented Dec 8, 2016

@igongora
Try to add fill Attr to each path/rect and etc.

And remove <style><\style>

@Crash--
Copy link

Crash-- commented Dec 8, 2016

@igongora : See #11

@matc4 matc4 closed this as completed Jan 18, 2017
@ghost
Copy link

ghost commented Feb 7, 2017

The same SVGs work if I use the uri property on a remote host, but do not work and show the "TypeError: invalid svg" error if I use the require syntax.

An example is the canonical tiger SVG that everybody uses for testing their implementations:
https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg

This tiger fails with the same error message when using require, but works when using uri. In fact, I haven't been able to get even the simplest SVG to work using require.

@ghost
Copy link

ghost commented Feb 7, 2017

With this one, I see the following:

TypeError: unsupported file type at lookup (/Users/tonydiepenbrock/rn/node_modules/image-size/lib/index.js:35:9) at /Users/tonydiepenbrock/rn/node_modules/image-size/lib/index.js:93:22 at /Users/tonydiepenbrock/rn/node_modules/image-size/lib/index.js:50:9 at /Users/tonydiepenbrock/rn/node_modules/graceful-fs/graceful-fs.js:43:10 at FSReqWrap.oncomplete (fs.js:112:15)

for the very simple example below:

<Svg
    height="100"
    width="100"
>
    <Circle
        cx="50"
        cy="50"
        r="50"
        fill="pink"
    />
</Svg>

Right now, loading SVGs "locally" seems to be completely broken.

@matc4
Copy link
Collaborator

matc4 commented Feb 7, 2017

Hi @tonydiepenbrock , do you check this part of the documentation?

[ANDROID] There is a problem with static SVG file on Android, Works OK in debug mode but fails to load the file in release mode. At the moment the only workaround is to pass the svg content in the svgXmlData prop.

@ghost
Copy link

ghost commented Feb 8, 2017

I am not using Android, I'm using iOS. Does it work with iOS?

@bansal-rahul
Copy link

@foobarnautT
+1

@bansal-rahul
Copy link

@chandlervdw
+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants