You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I have two API calls in the componentDidMount(). I want to wait until they are all finished before component mounts in. Is there efficient way to do it ? is there something like Promise.all() available?
Thanks,
Pawel
The text was updated successfully, but these errors were encountered:
Sure you can! Something like this should work in componentDidMount:
Promise.all([dispatch(requestCreatorOne()),dispatch(requestCreatorTwo())]).then(results)=>{if(results.some(r=>r.error)){// If there are any errors in the response, you could trigger an error path like sodispatch(componentFetchError())// OR by connecting the component to relevant redux store properties set by the request actions}else{// Otherwise, signal the UI that it should proceeddispatch(componentFetchSuccess())// OR connect your component to redux state set by the request actions}})
Hi,
I have two API calls in the componentDidMount(). I want to wait until they are all finished before component mounts in. Is there efficient way to do it ? is there something like Promise.all() available?
Thanks,
Pawel
The text was updated successfully, but these errors were encountered: