Add ErrorBoundary to page content

Prevent the page from turning into a black screen when page rendering
fails by adding an error boundary to the display of the page content in
SiteLayout.jsx.
This commit is contained in:
Hornwitser committed 2021-02-24 19:48:43 +01:00
1 parent ac17b8497a
commit b538960592
4 files changed
+50 -1

No files matched your search

@@ -3,6 +3,9 @@ import { Switch, Route, useHistory } from "react-router-dom";
import { Layout, Menu } from "antd";
import webUiPackage from "../../package.json";
import ErrorBoundary from "./ErrorBoundary";
import ErrorPage from "./ErrorPage";
const { Header, Sider } = Layout;
@@ -74,7 +77,9 @@ export default function SiteLayout(props) {
</Route>)}
{pages.map(page => <Route exact path={page.path} key={page.path}>
<SetSidebar path={page.sidebarPath} />
{page.content}
<ErrorBoundary Component={ErrorPage}>
{page.content}
</ErrorBoundary>
</Route>)}
<Route>
<SetSidebar path={null} />