Where did I get this code wrong? Set State with this.setState

Tell us what’s happening:

Your code so far

class MyComponent extends React.Component {
  constructor(props) {
    this.state = {
      name: 'Initial State'
    this.handleClick = this.handleClick.bind(this);
  handleClick() {
    // change code below this line
  this.setState({name: 'React Rocks'});
    // change code above this line
  render() {
    return (
        <button onClick={this.handleClick}>Click Me</button>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:69.0) Gecko/20100101 Firefox/69.0.

Link to the challenge:

You have a typo in the string that you are setting for name.

1 Like