Tell us what’s happening:
Describe your issue in detail here.
I’m having trouble understanding the instructions for this exercise. I am not exactly sure what questions I need to ask to get clarity on the instructions. But the following questions come to mind. What is a “click handler”? What does it mean to "pass a function to setState? What is a React “class method” and how is a method defined? What is the “constructor” and what is the “method” in the constructor?
**Your code so far**
class MyComponent extends React.Component {
constructor(props) {
super(props);
this.state = {
visibility: false
};
// Change code below this line
this.setState(state => ({
toggleVisbility
}));
// Change code above this line
}
// Change code below this line
// 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_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Challenge: Use State to Toggle an Element
Link to the challenge: