Let's assume that we want to import a vectorial.svg
using React. There are 2 options:
Import the .svg
as a React component:
jsximport React from 'react'; import { ReactComponent as Vectorial } from '../Assets/vectorial.svg'; const App = () => { return( <Vectorial/> ); } export default App;
Import the .svg
as an image:
jsximport React from 'react'; import Vectorial from '../Assets/vectorial.svg'; const App = () => { return( <img src = {Vectorial}/> ); } export default App;
Hi, I'm Erik, an engineer from Barcelona. If you like the post or have any comments, say hi.