Accepted answer

I guess the problem is the location of the image. When you use create-react-app the app will be bundle into the public folder. Then the require statement would start to fetch the image - in this case in relative to the public folder and not to the src folder.

What I suggest you to do is try to move the image into the public folder and try using the src with URL relative to the public folder. Demo here


use this one, it's work for me

<img src={require('./somRelativePath/image.jpg').default}

Explanation :

Value from let image1require('./somRelativePath/image.jpg') is different with import calendarPic from './somRelativePath/image.jpg';

If you console them, value from calendarPic is a path, but if you use require, the value is an object like here.

Related Query

More Query from same tag