Create a Stateful Component

Create a Stateful Component
0.0 0

#1

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


#2

State is an object so it should be like this:

this.state = {
name : “nametest”

}


#3

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


#4

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