I have a component, which relies on data to be asynchronously retrieved before the content is rendered. If the data is not yet available, the render function will return a Loader component instead:
if (this.state.loading) {
return <Loader />;
}
The state of loading is set to false after the call returns data:
componentDidMount() {
ExternalComponent.fetchData().then(response => {
this.setState({
loading: false,
data: response
});
});
}
This works ok, but what if I wanted to add in another async fetch call in parallel? How would I properly wait for both to finish before setting the state of 'loading' to false?
react-reduxtag, do you useredux?Reduxside. In the future maybe you remember this :)