DEV Community

Discussion on: How to make many http requests with react

Collapse
 
xngwng profile image
Xing Wang

if you have multiple callback asynchrous update the setState, you should consider this method to make sure they don't overwrite each other or race conditions:

this.setState( prevState => ({ ...prevState, work1: result });

this.setState( prevState => ({ ...prevState, work2: result });