JavaScript React Components Build Modular Interfaces with Components Setting up with Create React App

AF Content
AF Content
21,183 Points

Why can't I view React app in browser?

I set it up exactly as the video is telling me to, but for some reason when my app runs in the browser I see the React logo and then a message underneath that says "Edit src/App.js and save to reload." Instead of actually seeing the app in the browser.

Did I do something wrong or miss a step? I've rewatched the video a thousand times and can't seem to figure out what the problem is.

Dane Parchment
Dane Parchment
Treehouse Moderator 9,734 Points

Can I see your code? It's possible you are editing the wrong file, and so you aren't seeing the results change.

William Wei Luan Ting
William Wei Luan Ting
4,253 Points

I seem to remember having a similar issue when I started with React. I can't seem to remember the exact solution I did for this. If you post your code it will help. But here are my exact steps I use to setup a react environment from scratch.

Install Node.js Install VisualStudio Code from vs code's terminal install react by tying ins "npm install -g create-react-app" from any directory you can then type in "create-react-app my-app" a folder named my-app will be created, navigate to this directory and then type in "npm start"

if you do all the steps above it should work.

michael williams
michael williams
18,307 Points

it sounds like your code is working just fine. when you run npm start at first that is your first thing you see in react. when you run create-react-app you see the react logo and edit src/App.js next you need to delete the stuff inside of App.js and add your own content inside of App.js you import your components, and add them to the App.js file

import React from 'react';
import Header from './components/Header';

class App extends React.Component {
   render() {
        return (
         <div>
            <Header />
         </div>
      )
  }
export default App;

something similar to this... to kick it off. best of luck.