The site would be much better if it loaded a sample SVG by default so I don't have to hunt down the source for an SVG that I have lying around (or on the internet).
SVG2JSX – Convert SVG to Valid React SVG
21–30 of 30 posts
Re: SVG2JSX – Convert SVG to Valid React SVG
#22Related: Babel transform to load SVGs as React components: https://github.com/jhamlet/svg-react-loader
Re: SVG2JSX – Convert SVG to Valid React SVG
#23I thought parens around any SVG would make it valid JSX.
Re: SVG2JSX – Convert SVG to Valid React SVG
#24Re: SVG2JSX – Convert SVG to Valid React SVG
#25Re: SVG2JSX – Convert SVG to Valid React SVG
#26Re: SVG2JSX – Convert SVG to Valid React SVG
#27Is `xmlns` actually required? We've pulled it out of all of our React svg's and everything seems to work fine. Does anyone know of any quirks this could be causing?
Re: SVG2JSX – Convert SVG to Valid React SVG
#28For example, I could easily just run element.innerHTML = "" to add SVG content to my page. If the SVG isn't being dynamically updated, doesn't making JSX like this incur a large and unnecessary overhead?
Re: SVG2JSX – Convert SVG to Valid React SVG
#29I'm curious: what's the main use-case for this functionality? Particularly given it's a lossy transformation, I can't think of any situation where I'd use this.
hey lucideer, I think it's usefull when you had to work with SVG sprites + React. Converts the attributes not supported in React (xlink:href, fill-rule, etc.) to valid React attributes and also in case you have inline styles (eg. style="margin-left:20px") this tool will generate a Javascript object from that style ({marginLeft: 20}), which is valid React inline style. Also, I think it's super usefull in case you had…
That said though, I've used SVG in React quite a lot myself, but I've always opted for SVG as strings or external static resources rather than inlined vdom objects - this has worked fine for me as I would think of SVG as a display format so it has never needed granular access according to application state in my experience.