how to update state with props react js code example
Example 1: how to update state in react
// Correct
this.setState(function(state, props) {
return {
counter: state.counter + props.increment
};
});
Example 2: reactjs update state example
{
hasBeenClicked: false,
currentTheme: 'blue',
}