mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-15 09:46:16 +01:00
make error optional in state
This commit is contained in:
@@ -15,8 +15,7 @@ type Props = {
|
|||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
content: string,
|
content: string,
|
||||||
error: Error,
|
error?: Error,
|
||||||
hasError: boolean,
|
|
||||||
loaded: boolean
|
loaded: boolean
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,8 +25,6 @@ class SourcecodeViewer extends React.Component<Props, State> {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
content: "",
|
content: "",
|
||||||
error: new Error(),
|
|
||||||
hasError: false,
|
|
||||||
loaded: false
|
loaded: false
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -39,7 +36,6 @@ class SourcecodeViewer 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
|
||||||
});
|
});
|
||||||
@@ -55,13 +51,10 @@ class SourcecodeViewer extends React.Component<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const content = this.state.content;
|
const { content, error, loaded } = this.state;
|
||||||
const error = this.state.error;
|
|
||||||
const hasError = this.state.hasError;
|
|
||||||
const loaded = this.state.loaded;
|
|
||||||
const language = this.props.language;
|
const language = this.props.language;
|
||||||
|
|
||||||
if (hasError) {
|
if (error) {
|
||||||
return <ErrorNotification error={error} />;
|
return <ErrorNotification error={error} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user