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