Tell us what’s happening:
Hey just wanted to say that this code underneath is incorrect but it let me pass the challenge
Your code so far
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {
count: 0
};
// change code below this line
this.increment = this.increment.bind(this);
this.decrement = this.decrement.bind(this);
// I made a typo here, it should be
// this .reset = this.reset.bind(this);
// even though counter didnt reset to zero it let me pass
this.reset = this.decrement.bind(this);
// change code above this line
}
// change code below this line
increment(){
this.setState({ count: this.state.count + 1 });
}
decrement(){
this.setState({ count: this.state.count -1 });
}
reset(){
this.setState({ count: 0 });
}
// change code above this line
render() {
return (
<div>
<button className='inc' onClick={this.increment}>Increment!</button>
<button className='dec' onClick={this.decrement}>Decrement!</button>
<button className='reset' onClick={this.reset}>Reset</button>
<h1>Current Count: {this.state.count}</h1>
</div>
);
}
};
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:60.0) Gecko/20100101 Firefox/60.0
.
Link to the challenge:
https://learn.freecodecamp.org/front-end-libraries/react/write-a-simple-counter