0

Theoretically, I know that the state's changes in the hook setState are aggregated, i.e if I'll call it multiple times in the same function, the state's changes will be collected, and then the state will be changed only once.

Is this is the case for this.setState in React's Component class as well? For example, if I would want to add multiple calls to this.setState on componentDidMount?

Thanks.

Yoav Abadi
  • 403
  • 7
  • 16
  • can you give an example of wanting to do this? if you want to update multiple state you can do `this.setState({thingA: 123, thingB: 456})` – Red Baron Jun 16 '20 at 06:20
  • 1
    State updates are only batched within event handlers. Please read the duplicate post where @DanAbramov addresses those points – Shubham Khatri Jun 16 '20 at 06:21

0 Answers0