Hi guys, this doesn't work for me though everything looks correct. Can anyone help me with this? Thanks!

Hi guys, this doesn't work for me though everything looks correct. Can anyone help me with this? Thanks!
0.0 0

#1

Tell us what’s happening:

Your code so far


class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visibility: false
    };
    // change code below this line
      this.toggleVisibility = this.toggleVisibility.bind(this);
    // change code above this line
  }
  // change code below this line
toggleVisibility(){
  if(this.state.visibility = true){
    this.setState =({
     visibility: false
    });
  } else{
    this.setState=({
      visibility: true
    });
  }
}
  // change code above this line
  render() {
    if (this.state.visibility) {
      return (
        <div>
          <button onClick={this.toggleVisibility}>Click Me</button>
          <h1>Now you see me!</h1>
        </div>
      );
    } else {
      return (
        <div>
          <button onClick={this.toggleVisibility}>Click Me</button>
        </div>
      );
    }
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/11.0.1 Safari/604.3.5.

Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/use-state-to-toggle-an-element


#2

Maybe you meant == or ===?

this.setState here is a function call, so there shouldn’t be the = character after setState.


#3

Thanks, that helped and problem solved.!!!


#4

hi, i need help =>string abbreviation in Javascript program