← React Intermediate Questions - Set 9 Q83

How do you handle state in class components?

React Intermediate Questions - Set 9

Example

this.setState({ open: true });            // merge
this.setState(prev => ({ n: prev.n + 1 }));  // when it depends on the previous value

What to notice

← Back to the question list