Current pushing through the React section of Front End Development Libraries and on Use State to Toggle an Element the damn “run the tests” button refuses to check my work. Just does nothing. Inspector shows <button type="button" class="btn btn-primary btn-block">Run the Tests</button> == $0
Tested with both the current Firefox and Chrome to no avail. Anyone else having this issue?
Full code for examination. I think it’s right but even if it’s incorrect the “Run The Tests” button helps me figure out where I went amiss =)
Thanks for any help!
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() {
this.setState(state => {
if (state.visibility === true) {
return { visibility: false };
} else {
return { 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>
);
}
}
}
Thank you for the tip! Guess reddit habits got the better of me for posting code =)
Gah! Found it, extra “}” borked it for me. Issue resolved, sorry for wasting everyone’s time. I will be more critical next time. Thanks again for your time and kind attention, cheers.