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 Create a Component

Stephen Garcia
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Garcia
Python Development Techdegree Student 11,647 Points

Trouble displaying

getting a syntax error on line 3 of unexpected token '<'. I swear it looks the same as the video and I even restarted the project. If anyone can see the problem it would be much appreciated

https://github.com/StephenDGarcia/React_Scoreboard

4 Answers

Stephen Garcia
seal-mask
.a{fill-rule:evenodd;}techdegree
Stephen Garcia
Python Development Techdegree Student 11,647 Points

That didn't seem to work. I'm copying the code from the Use a Component with JSX video at 00:37. Could it possibly be with my index.html and the React CDM's being older and needing updates?

Austin Whipple
Austin Whipple
29,725 Points

It looks like you're going to need to wrap that chunk of HTML in backticks ( `) to tell the browser that it should expect interpolated HTML instead of more script instructions.

function Header () {
     return (
         `<header>
             <h1>Scoreboard</h1>
             <span>Players: 1</span>
         </header>`
     );
}
Louie Ambriz
Louie Ambriz
7,639 Points

I'm having the same issue with this. I literally downloaded the files with the lesson and copied them and transferred them into the work space I and seeing the same error as Stephen.

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

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

I found a possible solution here: https://stackoverflow.com/questions/44861564/react-jsx-error-unclosed-regular-expression.

Uninstalling JShint seems to help.