Bind to a Class Method

Tell us what’s happening:
The code is satisfying the requirement but it says “invalid arrow-function arguments (parentheses around the arrow-function may help)”

Your code so far


class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      itemCount: 0
    };
    // change code below this line
    this.addItem = this.addItem.bind(this)
    // change code above this line
  }
  addItem() {
    this.setState({
      itemCount: this.state.itemCount + 1
    });
  }
  render() {
    return (
      <div>
        { /* change code below this line */ }
        <button onClick={this.addItem}>Click Me</button>
        { /* change code above this line */ }
        <h1>Current Item Count: {this.state.itemCount}</h1>
      </div>
    );
  }
};

Your browser information:

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0.

I’ve tried this on my side. It works perfectly and the console doesn’t show any error messages :man_shrugging:

Hey, thank you for checking the code. But in my console it has been showing the error since React: Render State in the User Interface.

If your code is passing the tests, I wouldn’t worry about it too much. Besides, it looks like an error since no arrow functions are being called.

In what environment are you getting these error messages ? On the FCC console ?

Yes, there is no arrow function being called. The error message is on the FCC console.