1

I have changed the images path from this src={../images/${props.data.coverImg}}

To this src={images/${props.data.coverImg}}

and the interesting thing is that when I install gh-pages, images are broken on local host-3000 but it displays on gh-pages.

I have stored images folder in public folder.

Sahil
  • 11
  • 1
  • 1
  • 4

1 Answers1

0

Try to add ./ before the img src:

 src={./images/${props.data.coverImg}}

I think there is a differnets in the way your browser rendering the url of the images, between localhost and a real environment.

The scion
  • 1,001
  • 9
  • 19
  • I have tried that, but still not working, I have created an array of objects where I have mentioned the images name, and I'm dynamically accessing them src={images/${props.data.coverImg} and the image folder is in public, it happens when I install gh-pages. is there any other way? – Sahil Feb 10 '22 at 08:09
  • https://stackoverflow.com/questions/41947474/dynamically-loading-local-images-with-reactjs – The scion Feb 10 '22 at 08:22
  • Still not working man!
    Star Array of Objects coverImg: "usa.png", stats: { rating: 5.0, reviewCount: 6 } and image folder is in public and I'm using props to access the images
    – Sahil Feb 10 '22 at 09:23