// Wrong
this.setState({
counter: this.state.counter + this.props.increment,
});
// Wrong
const { counter } = this.state;
const { increment } = this.props;
this.setState({
counter: counter + increment,
});
// Correct
this.setState((prevState, props) => ({
counter: prevState.counter + props.increment
}));