]> Untitled Git - lemmy-ui.git/blob - src/shared/components/common/error-guard.tsx
Merge branch 'main' into rate-limiting-tab
[lemmy-ui.git] / src / shared / components / common / error-guard.tsx
1 import { Component } from "inferno";
2 import { setIsoData } from "../../utils";
3 import { ErrorPage } from "../app/error-page";
4
5 class ErrorGuard extends Component<any, any> {
6   private isoData = setIsoData(this.context);
7
8   constructor(props: any, context: any) {
9     super(props, context);
10   }
11
12   render() {
13     const errorPageData = this.isoData.errorPageData;
14     const siteRes = this.isoData.site_res;
15
16     if (errorPageData || !siteRes) {
17       return <ErrorPage />;
18     } else {
19       return this.props.children;
20     }
21   }
22 }
23
24 export default ErrorGuard;