Reputation: 181
I want to load multiple SVG icons in a react component. but the component only load first SVG and others shown as a square or repeat first SVG icon i load the SVG like this
import { ReactComponent as Back} from "./back.svg";
and use it as a component
I tried to load svg file and use img tag but it has another issue to...
I didn't use any third-party package to load SVG what is the best way to import SVG file in react js
Upvotes: 1
Views: 1029
Reputation: 181
I found what's the problem... I had multiple SVG files that all of them had the same id in them... when I load them together, the page had multiple tags with the same id and only show one image or an empty square
I changed each SVG tag's id and everything is OK now
Upvotes: 4