};
state = { data: null };
componentDidMount() {
fetch(`/tasks?id=${this.props.id}`)
.then(response => response.json())
.then(data => this.setState({data}));
}
render() {
if (!this.state.data) {
return <ActivityIndicator />
} else {
return (
...
);
}
}
}