From e1f8f13550a31286e2ca9f26c459dc78301e85ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maren=20S=C3=BCwer?= Date: Thu, 1 Nov 2018 10:59:04 +0100 Subject: [PATCH] make error optional in state --- .../sources/components/content/SourcecodeViewer.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) 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 ; }