Create a Stateful Component help i'm stuck

Tell us what’s happening:

Your code so far



class StatefulComponent extends React.Component {
  constructor(props) {
    super(props);
    // initialize state here
this.state = {
  
}
  }
  render() {
    return (
      <div>
        <h1>{this.state.name}</h1>
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36.

Link to the challenge:

There is a component in the code editor that is trying to render a name property from its state . However, there is no state defined. Initialize the component with state in the constructor and assign your name to a property of name .

So in the render it tries to print out the name property of the state object. Your state object has no propertys.
You need to add a name property and assign it to a string of your choice.

1 Like