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 React Basics (2018) Thinking in Components Composing Components

Alex Burtson
Alex Burtson
6,228 Points

Why am I not seeing anything on screen?

I'm using the workspace and I have all the same code as what's in the exercise, but nothing is showing on screen. I'm not even getting console errors.

Here is my code in app.js:

const Header = () => {
  return (
    <header>
      <h1>Scoreboard</h1>
      <span className="stats">Players: 1</span>
    </header>
  );
}

const Player = () => {
  return (
    <div className="player">
      <span className="player-name">
        Guil
      </span>

      <Counter />
    </div>
  );
}

const Counter = () => {
  return (
      <div className="counter">
        <button className="counter-action decrement"> - </button>
        <span className="counter-score"></span>
        <button className="counter-action increment"> + </button>
      </div>
  );
}

const App = () => {
  return (
    <div className="scoreboard">
      <Header />

      {/* Players list */}
      <Player />
    </div>
  );
}

ReactDOM.render(
  <App />,
  document.getElementById('root')
);

And here's the code in index.html:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>Scoreboard</title>
    <link rel="stylesheet" href="./app.css" />
  </head>

  <body>
    <div id="root"></div>
    <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script type="text/babel" src="./app.js"></script>
  </body>
</html>

Does anyone know why nothing would be showing?

Thanks in advance!

1 Answer

Your html is missing a babel script just above the one for app.js

  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>
    <script type="text/babel" src="./app.js"></script>

Did you download the project files or launch workspace from the video?