diff --git a/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js index c19338e639..e54f8e1b3b 100644 --- a/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js +++ b/scm-ui/src/repos/sources/components/content/SourcecodeViewer.js @@ -15,8 +15,7 @@ type Props = { type State = { content: string, - error: Error, - hasError: boolean, + error?: Error, loaded: boolean }; @@ -26,8 +25,6 @@ class SourcecodeViewer extends React.Component { this.state = { content: "", - error: new Error(), - hasError: false, loaded: false }; } @@ -39,7 +36,6 @@ class SourcecodeViewer extends React.Component { if (result.error) { this.setState({ ...this.state, - hasError: true, error: result.error, loaded: true }); @@ -55,13 +51,10 @@ class SourcecodeViewer extends React.Component { } render() { - const content = this.state.content; - const error = this.state.error; - const hasError = this.state.hasError; - const loaded = this.state.loaded; + const { content, error, loaded } = this.state; const language = this.props.language; - if (hasError) { + if (error) { return ; }