3 ms·
This is possible in React apps bootstrapped with "create-react-app". create-react-app version 2.0 added a lot of new features. One of the new features is added
by dstroot 8y ago
This is possible in React apps bootstrapped with "create-react-app". create-react-app version 2.0 added a lot of new features. One of the new features is added the svgr webpack loader to wrap SVGs in React components as a named export. This lets you either grab the filename from the default export or grab a wrapped SVG component depending on your needs.
In other words you can do this in react now without any extra "stuff". Syntax:
import { ReactComponent as Logo } from './logo.svg';
- jansan 8y agoHow does it handle IDs if the same SVG is included multiple times or if different SVGs use the same IDs? With SVG, if you want to use gradients, filters, patterns, symbols, etc. there is no other way than using IDs. And if they are not handled properly, and webpack certainly does not do it properly, you may run into trouble with more complex SVGs, dynamic adding of SVGs, etc.
- deleted 8y ago[deleted]