0

I have:

import {ReactComponent as IconSaveTag} from 'src/assets/IconSaveTag.svg'; and use: <IconSaveTag/>

Now How to: import IconSaveTag from 'src/assets/IconSaveTag.svg'; and can use: <IconSaveTag />

I tried researching and using npm @svgr/cli but was not successful

Siddharth Seth
  • 643
  • 5
  • 18
Kiet Vo
  • 1
  • 1
  • What's wrong with using `import {ReactComponent as IconSaveTag}`? What you also can do is create a js file called IconSaveTag.js and paste the SVG code in and export it as a component. – Jelmer Overeem Mar 05 '23 at 15:34
  • Is there a way to configure it without using the .js file? I used: import { ReactComponent as IconSaveTag} .... can export \ but I don't want every svg file to use {ReactComponent as...} – Kiet Vo Mar 06 '23 at 02:32
  • Please provide enough code so others can better understand or reproduce the problem. – Community Mar 06 '23 at 08:01
  • Here are 2 links to different ways to use svgs in React. https://stackoverflow.com/a/42296853/13664713 https://blog.logrocket.com/how-to-use-svgs-react/#use-svgs-react But why don't you want to use {ReactComponent as...}? – Jelmer Overeem Mar 07 '23 at 08:44
  • Because I want to know how to configure it. Every svg uses "ReactComponent as..." which I don't like. Thanks for the solution – Kiet Vo Mar 07 '23 at 13:17

0 Answers0