react-svg-wrapper
A React component for injecting an SVG file or string into the DOM.
- stack
- React, JavaScript
On the workbench
- <SVGWrapper src type />Takes an SVG file or an SVG string, plus any normal HTML or SVG props you want on it.
- A depth-first walkGoes through the SVG’s tree and puts it into the DOM, so your app can control it like any other element.
Build log
- Jan 2022 Published to npm as a zero-dependency package.
What it taught me
- You often don’t need a dependency: a small depth-first walk over the DOM did the job.