Merged in feature/diff_always_loading_when_no_diff (pull request #137)

Feature/diff always loading when no diff
This commit is contained in:
Sebastian Sdorra
2018-12-20 09:29:36 +00:00

View File

@@ -30,6 +30,16 @@ class LoadingDiff extends React.Component<Props, State> {
}
componentDidMount() {
this.fetchDiff();
}
componentDidUpdate(prevProps: Props) {
if(prevProps.url !== this.props.url){
this.fetchDiff();
}
}
fetchDiff = () => {
const { url } = this.props;
apiClient
.get(url)
@@ -46,15 +56,18 @@ class LoadingDiff extends React.Component<Props, State> {
error
});
});
}
};
render() {
const { diff, loading, error } = this.state;
if (error) {
return <ErrorNotification error={error} />;
} else if (loading || !diff) {
} else if (loading) {
return <Loading />;
} else {
} else if(!diff){
return null;
}
else {
return <Diff diff={diff} />;
}
}