Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Introducing the Practice

William Wei Luan Ting
William Wei Luan Ting
4,254 Points

Broken images - create-react-app with VS code

So I copied the final code from this course and pasted it into index.js, index.css, and index.html in my create-react-app when I load it I see all the cards and the styling and text all look right however the image does not show up. If I change the url from a relative path to a random absolute img on the web it does work. Why is this happening?

William Wei Luan Ting
William Wei Luan Ting
4,254 Points

Okay just figured this out. I had to move the img folder inside the public folder. Because the relative path is to index.html and not index.js

2 Answers

try to move your images folder to public folder and see if it works.

Greetings,

The same thing happened to me and I was able to fix it by moving it to the public folder as well. However, I would like to understand the 'Why' better. Would you mind sharing (0r provide a link that goes through why this happened)?