React - Render State in the User Interface Another Way

*Tell us what’s happening:
the code is correct but I’m stuck with this error:
" The rendered h1
heading element should contain text rendered from the component’s state."

  **Your code so far**
class MyComponent extends React.Component {
constructor(props) {
  super(props);
  this.state = {
    name: 'freeCodeCamp'
  }
}
render() {
  // Change code below this line
  const name = this.state.name;
  // Change code above this line
  return (
    <div>
      { /* Change code below this line */ }
      <h1>{name} </h1>
      { /* Change code above this line */ }
    </div>
  );
}
};

Challenge: React - Render State in the User Interface Another Way

Link to the challenge:

<h1>{name} </h1>
          ↑

Why did you add an extra space there?

3 Likes

thanks, I didn’t even notice :man_facepalming: