Procházet zdrojové kódy

Prevent render objects on CurrentError component

jnfrati před 4 roky
rodič
revize
aaa028390a
1 změnil soubory, kde provedl 6 přidání a 2 odebrání
  1. 6 2
      dashboard/src/main/CurrentError.tsx

+ 6 - 2
dashboard/src/main/CurrentError.tsx

@@ -26,11 +26,15 @@ export default class CurrentError extends Component<PropsType, StateType> {
   }
   }
 
 
   render() {
   render() {
+    let currentError = this.props.currentError;
+    if (!React.isValidElement(this.props.currentError)) {
+      currentError = String(this.props.currentError);
+    }
     if (this.props.currentError) {
     if (this.props.currentError) {
       if (!this.state.expanded) {
       if (!this.state.expanded) {
         return (
         return (
           <StyledCurrentError>
           <StyledCurrentError>
-            <ErrorText>Error: {this.props.currentError}</ErrorText>
+            <ErrorText>Error: {currentError}</ErrorText>
             <ExpandButton onClick={() => this.setState({ expanded: true })}>
             <ExpandButton onClick={() => this.setState({ expanded: true })}>
               <i className="material-icons">launch</i>
               <i className="material-icons">launch</i>
             </ExpandButton>
             </ExpandButton>
@@ -53,7 +57,7 @@ export default class CurrentError extends Component<PropsType, StateType> {
         <Overlay>
         <Overlay>
           <ExpandedError>
           <ExpandedError>
             Porter encountered an error. Full error log:
             Porter encountered an error. Full error log:
-            <CodeBlock>{this.props.currentError}</CodeBlock>
+            <CodeBlock>{currentError}</CodeBlock>
             <ExpandButtonAlt onClick={() => this.setState({ expanded: false })}>
             <ExpandButtonAlt onClick={() => this.setState({ expanded: false })}>
               <i className="material-icons">remove</i>
               <i className="material-icons">remove</i>
             </ExpandButtonAlt>
             </ExpandButtonAlt>