React - Write a Simple Counter

Tell us what’s happening:

I have done evreything it said but I didnt find any mistakes. What should I do now.

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);
    this.reset = this.reset.bind(this);
    // Change code above this line
  }
  // Change code below this line
  increment() {
    setState(state => ({count: state.count + 1}))
  };
  decrement() {
    setState(state => ({count: state.count - 1}))
  };
  reset() {
    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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Mobile Safari/537.36

Challenge Information:

React - Write a Simple Counter

Remember setState is a method on this

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.