React doesn't display images placed in public folder when I install gh-pages but when I push the code it displays in gh-pages?

Viewed 76

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.

1 Answers

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.

Related