OK last hail mary here. I've seen this question a lot but no clear answer. I moved all of my images out of my src
folder to my public
folder into a sub-folder images
. And used the URL like ./images/my-image.png
but the image isn't populating. I am using create-react-app. How do I call images from a public
folder outside of my src
folder.
OK last hail mary here. I've seen this question a lot but no clear answer. I moved all of my images out of my src
folder to my public
folder into a sub-folder images
. And used the URL like ./images/my-image.png
but the image isn't populating. I am using create-react-app. How do I call images from a public
folder outside of my src
folder.
- 1 Does this answer your question? ReactJS and images in public folder – Mohammad Hooshdar Commented Apr 15, 2022 at 8:04
2 Answers
Reset to default 2change the src from /public/images
to /images
This is what worked for me:
src:(process.env.PUBLIC_URL+"/images/image-name.jpg")