Create a Stateful Component

Tell us what’s happening:
I am not sure if there’s a bug or something but running tests doesn’t do anything.
Can someone verify if I have the syntax correct at least?
Thanks

Your code so far


class StatefulComponent extends React.Component {
  constructor(props) {
    super(props);
    // initialize state here
    this.state = {
      name = "nametest"
    }
  }
  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/66.0.3359.181 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/create-a-stateful-component

State is an object so it should be like this:

this.state = {
name : “nametest”

}

2 Likes

oh wow… thanks for clearing that up.
major brain fart on my part :stuck_out_tongue:

jajajaj odnt worry mate it happens all the time :smile: