React - Create a Stateful Component

Tell us what’s happening:
Describe your issue in detail here.

  **Your code so far**
class StatefulComponent extends React.Component {
constructor(props) {
  super(props);
  // initialize state here
  
  this.state = {
    name : "Name"
  }

}
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/105.0.0.0 Safari/537.36

Challenge: React - Create a Stateful Component

Link to the challenge:

Hello there.

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

Hi, in the challenge, the state must be set with “firstName” and not “name”.
Your code is good, but the test will fail.

With your code you’ll get the error :
" The state of StatefulComponent should be initialized with a property firstName"

1 Like