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 trialLuke Markham
Front End Web Development Techdegree Graduate 17,289 PointsImporting CSS into a J.S file
I'm just curious what is happening here? The CSS is not linked in index.html.
So I believe it's included in the mounting done in the <div id="root"></div
Is it somehow complied by React-app? if so what's it compiled into ? How can the browser know its CSS when its in a JS file ?
2 Answers
Tashan Duncan
Front End Web Development Techdegree Graduate 17,799 PointsHi Luke,
the compiling of the CSS is handled via Webpack which was installed with 'create-react-app'.
More information here: https://create-react-app.dev/docs/adding-a-stylesheet
cnl
Full Stack JavaScript Techdegree Graduate 20,431 PointsHad the same hiccup with CSS, give this a try:
1) Downloading the files in the "Downloads" section of the video after running npx create-react-app my-app 2) Open scoreboards inside of the recently created React edition of scoreboards. 3) Replace src folder with the one provided in the "Downloads" section (it'll have a component folder) 4) Optional: if preferring the code from React Basics in app.js, copy and paste it in to update
Happy Coding!