chrvadala / react-svg-pan-zoom

:eyes: A React component that adds pan and zoom features to SVG
https://chrvadala.github.io/react-svg-pan-zoom/
MIT License
681 stars 127 forks source link

Loading SVG from component using create-react-app #145

Closed andrewleith closed 5 years ago

andrewleith commented 5 years ago

I am loading my SVGs as components as per the CRA docs:

import { ReactComponent as FloorPlan } from "../../images/floorplan.svg";

When I try to use the <FloorPlan /> component inside of <ReactSVGPanZoom> I get the some errors and no SVG is displayed. If I copy the contents of floorplan.svg directly it works just fine. Can someone tell me what I'm doing wrong?

Thanks!

chrvadala commented 5 years ago

If you want to dynamically load a SVG content, you have to use this external dependency https://github.com/nufaylr/react-svg-pan-zoom-loader