Inconsistent setState usage in "React: Optimize Re-Renders with shouldComponentUpdate"

Inconsistent setState usage in "React: Optimize Re-Renders with shouldComponentUpdate"
0

In the lesson React: Optimize Re-Renders with shouldComponentUpdate, setState is used in a way that was discouraged in a previous lesson. In this lesson, it’s used as:

  addValue() {
    this.setState({
      value: this.state.value + 1
    });
  }

Shouldn’t this be used with a callback to ensure that the state is correct when it’s eventually executed?

  addValue() {
    this.setState(state => ({
      value: state.value + 1
    }));
  }

Just noticed this as well. Glad I’m not the only one.