Here is a simple non-react solution.
- Install Svg inline loader
- In webpack.config.js add
{ test: /\.svg$/, loader: 'svg-inline-loader' }
- In your js file import svg image and add it to a DOM element like so
import Svg from './svg.svg';
function component() {
const element = document.createElement('div');
element.innerHTML = Svg;
return element;
}
document.body.appendChild(component());