Correct way to update State using the existing state:
this.setState((state, props) => ({
property: state.counter + props.increment
}));
or using regular functions:
this.setState(function(state, props) {
return {
counter: state.counter + props.increment
};
});
Comments
Post a Comment