0

I am trying to read images from folder in reactJS application. I tried with this Solution that is very close to my question on SO but console showing me this error each time.

Here is my code

<img src={require('../images/Mobile/Grab & Go.png')} alt="" />

Console is showing this error

Portfolio.jsx:23 Uncaught ReferenceError: require is not defined

Qazi Ammar
  • 953
  • 1
  • 8
  • 23

1 Answers1

1

You have to import the image then use it as a value passed to the src prop of img.

import Image from '../images/Mobile/Grab & Go.png';
...
<img src={Image} alt="" />
Ken Labso
  • 885
  • 9
  • 13