How Import Svg In React. A lightweight alternative solution to svgr is react-svg-loader. Our variable will hold a URL to the SVG icon.
Lastly import the file in your React app. How to import image svg png in a React Component. Import SVG using svg-react-loader - A webpack loader allowing for inline usage of a SVG as a React component as mentioned on the github page.
Npm install --save-dev babel-plugin-inline-react-svg Now lets add that plugin to our babelrc file.
Npm install --save-dev babel-plugin-inline-react-svg Now lets add that plugin to our babelrc file. 2 3 const App 4 5 6 7 javascript. If you are using Webpack you can also use a simplified SVG loader instead of SVGR. You can put your SVG files anywhere in your src folder and import them wherever you need them as React components.