import svg react typescript code example

Example 1: importing svg into react

import React from 'react';
import { ReactComponent as BrandIcon } from "./assets/brand-icon.svg";

export default function(){
  return( 
      <div>
          <BrandIcon />
      </div>
   );
}

Example 2: Cannot find module '../../images/home.svg' or its corresponding type declarations

// custom.d.ts on root /

declare module '*.svg?inline' {
  const content: any
  export default content
}

declare module '*.svg' {
  const content: any
  export default content
}

Example 3: import svg react

import React from 'react';
import LogoName from '../assets/logo.svg'

const Header = () => {
    return ( 
        <div>
           	<img src={LogoName} alt="logo"/>
        </div>
     );
}