DEV Community

Discussion on: How to create an extremely reusable Icon component with react-svg

Collapse
 
z2lai profile image
z2lai

How does this compare to using SVGR that's built-in with create react app v2. You can import the svg file as a React component in one line:


import { ReactComponent as Icon } from '. /icons/icon.svg'
Collapse
 
vtrpldn profile image
Vitor Paladini

react-svg lets you dynamically import SVG files so you can spec the SVG file name in the Icon name prop and it'll do the rest :)

Collapse
 
z2lai profile image
z2lai

Oh right, that's an excellent benefit. Now the post title makes sense :D. Thanks a lot!

Thread Thread
 
vtrpldn profile image
Vitor Paladini

Glad I could help!