how to set state for class component code example
Example 1: this setstate previous state react
state = {count: 0}
increment = () => {
this.setState(previousState => ({
count: previousState.count + 1
}))
}
Example 2: reactjs update state example
{
hasBeenClicked: false,
currentTheme: 'blue',
}