tigt/mini-svg-data-uri

Going the other direction

Closed this issue · 2 comments

Hi, I want to use this package to inline svgs with Webpack asset modules.

When I render them, though, I want to take the data URI and convert it back to plain SVG data so I can dangerouslySetInnerHTML. This way I can control things like the fill color with CSS.

Any suggestions on how to achieve that?

Nvm, react-inlinesvg does this for me:

<InlineSVG src={src} />

src can be literally anything, including a remote URL or a data URI. Very nice. Thanks for this nice script.

tigt commented

Nice to see you found a solution. If you or anyone else viewing this issue are curious how to do it vanilla, I’m pretty sure reversing the output is doable through decodeURIComponent().