I have to display an image in my project so I gave a relative path in src properties but it is not working.
Anyone suggest me a solution.
Thanks
You can import image as a component and directly use it:
import { ReactComponent as Logo } from "../../assets/logo.png";
And
<Logo className={classes.logo} />
You need to use the import
instead of passing a path as a string.
import React from 'react';
import logo from './logo.png';
function Header() {
return <img src={logo} alt="Logo" />;
}
export default Header;
For more information please visit documentation