Added ErrorBoundary to MarkdownView to avoid invalid markdown crashes the entire page

This commit is contained in:
Sebastian Sdorra
2020-03-24 07:38:07 +01:00
parent c86efe1a24
commit d3a8af7a52
4 changed files with 76 additions and 18 deletions

View File

@@ -3,6 +3,7 @@ import { withRouter, RouteComponentProps } from "react-router-dom";
// @ts-ignore
import Markdown from "react-markdown/with-html";
import { binder } from "@scm-manager/ui-extensions";
import ErrorBoundary from "./ErrorBoundary";
import SyntaxHighlighter from "./SyntaxHighlighter";
import MarkdownHeadingRenderer from "./MarkdownHeadingRenderer";
@@ -64,15 +65,17 @@ class MarkdownView extends React.Component<Props> {
}
return (
<div ref={el => (this.contentRef = el)}>
<Markdown
className="content"
skipHtml={skipHtml}
escapeHtml={skipHtml}
source={content}
renderers={rendererList}
/>
</div>
<ErrorBoundary>
<div ref={el => (this.contentRef = el)}>
<Markdown
className="content"
skipHtml={skipHtml}
escapeHtml={skipHtml}
source={content}
renderers={rendererList}
/>
</div>
</ErrorBoundary>
);
}
}