Home > Net >  i keep getting the same error when i try to import an image wheter its png,jpg or svg. module not fo
i keep getting the same error when i try to import an image wheter its png,jpg or svg. module not fo

Time:12-08

import React from "react";
import logo from "./logo.svg"



function NavBar() {
    return (
        <div className="navBar">
        <button>Manual</button>
        <button>Scenarios</button>
        <button><img src={logo}/></button>
        <button></button>
        <button></button>
        </div>
    );
    
}
export default NavBar;

im getting this: Compiled with problems:

ERROR in ./src/components/NavBar.jsx 5:0-30

Module not found: Error: Can't resolve './logo.svg' in 'C:\Users\andri\Documents\myReact\rushing-ranges\src\components'

i have tried importing from folder images and also from root of src

CodePudding user response:

use require keyword when giving path

 <img src={require('./logo.svg')}/>
  • Related