mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-06 05:25:44 +01:00
make error in state optional
This commit is contained in:
@@ -32,10 +32,9 @@ type Props = {
|
||||
type State = {
|
||||
contentType: string,
|
||||
language: string,
|
||||
error: Error,
|
||||
hasError: boolean,
|
||||
loaded: boolean,
|
||||
collapsed: boolean
|
||||
collapsed: boolean,
|
||||
error?: Error,
|
||||
};
|
||||
|
||||
const styles = {
|
||||
@@ -54,8 +53,6 @@ class Content extends React.Component<Props, State> {
|
||||
this.state = {
|
||||
contentType: "",
|
||||
language: "",
|
||||
error: new Error(),
|
||||
hasError: false,
|
||||
loaded: false,
|
||||
collapsed: true
|
||||
};
|
||||
@@ -68,7 +65,6 @@ class Content extends React.Component<Props, State> {
|
||||
if (result.error) {
|
||||
this.setState({
|
||||
...this.state,
|
||||
hasError: true,
|
||||
error: result.error,
|
||||
loaded: true
|
||||
});
|
||||
@@ -179,13 +175,12 @@ class Content extends React.Component<Props, State> {
|
||||
render() {
|
||||
const { file, classes } = this.props;
|
||||
const error = this.state.error;
|
||||
const hasError = this.state.hasError;
|
||||
const loaded = this.state.loaded;
|
||||
|
||||
if (!file || !loaded) {
|
||||
return <Loading />;
|
||||
}
|
||||
if (hasError) {
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user