React js - Crea un componente de estado

No entiendo como debo inicializar el estado del componente StateFulComponent

Tu código hasta el momento

class StatefulComponent extends React.Component {
  constructor(props) {
    super(props);
    // Only change code below this line
this.state = {
  name : "FirstName"
}
    // Only change code above this line
  }
  render() {
    return (
      <div>
        <h1>{this.state.firstName}</h1>
      </div>
    );
  }
};

Información de tu navegador:

El agente de usuario es: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36

Desafío: React js - Crea un componente de estado

Enlaza al desafío:

Inicia el componente con state en el constructor y asigna tu nombre a la propiedadfirstName .

You have:

this.state = {
  name : "FirstName"
}

You have created a property “name” and give it the value “FirstName”.

You were asked to create a property “firstName” and give it the property of your name.

For example, if I was asked to do that with my last name, I would do:

this.state = {
  lastName : "Smith"
}

You are asked to do that with the property “firstName” and with your own first name.

1 Like