@@ -7,6 +7,7 @@ import { RelayEnvironmentProvider } from "react-relay";
|
|||||||
import { BrowserRouter, Route, Routes } from "react-router";
|
import { BrowserRouter, Route, Routes } from "react-router";
|
||||||
import "App.css";
|
import "App.css";
|
||||||
import ErrorBoundary from "./components/ErrorBoundary";
|
import ErrorBoundary from "./components/ErrorBoundary";
|
||||||
|
import { ErrorPage } from "./pages/ErrorPage";
|
||||||
import ConsoleLayout from "./layouts/ConsoleLayout";
|
import ConsoleLayout from "./layouts/ConsoleLayout";
|
||||||
import { RelayEnvironment } from "./RelayEnvironment";
|
import { RelayEnvironment } from "./RelayEnvironment";
|
||||||
|
|
||||||
@@ -30,23 +31,80 @@ const FrameworkOverviewPage = lazy(() => import("./pages/FrameworkOverviewPage")
|
|||||||
function App() {
|
function App() {
|
||||||
return (
|
return (
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<ErrorBoundary fallback={<p>Something went wrong</p>}>
|
<ErrorBoundary>
|
||||||
<PostHogProvider client={posthog}>
|
<PostHogProvider client={posthog}>
|
||||||
<RelayEnvironmentProvider environment={RelayEnvironment}>
|
<RelayEnvironmentProvider environment={RelayEnvironment}>
|
||||||
<HelmetProvider>
|
<HelmetProvider>
|
||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Suspense>
|
<Routes>
|
||||||
<Routes>
|
<Route
|
||||||
<Route path="/" element={<ConsoleLayout />}>
|
path="/"
|
||||||
<Route index element={<HomePage />} />
|
element={
|
||||||
<Route path="/peoples" element={<PeoplesPage />} />
|
<ErrorBoundary>
|
||||||
<Route path="/vendors" element={<VendorList />} />
|
<ConsoleLayout />
|
||||||
<Route path="/frameworks" element={<FrameworksPage />} />
|
</ErrorBoundary>
|
||||||
<Route path="/frameworks/:frameworkId" element={<FrameworkOverviewPage />} />
|
}
|
||||||
</Route>
|
>
|
||||||
<Route path="*" element={<NotFoundPage />} />
|
<Route
|
||||||
</Routes>
|
index
|
||||||
</Suspense>
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<HomePage />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/peoples"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<PeoplesPage />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/vendors"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<VendorList />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/frameworks"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<FrameworksPage />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/frameworks/:frameworkId"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<ErrorBoundary>
|
||||||
|
<FrameworkOverviewPage />
|
||||||
|
</ErrorBoundary>
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="*"
|
||||||
|
element={
|
||||||
|
<Suspense>
|
||||||
|
<NotFoundPage />
|
||||||
|
</Suspense>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</Route>
|
||||||
|
</Routes>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
</HelmetProvider>
|
</HelmetProvider>
|
||||||
</RelayEnvironmentProvider>
|
</RelayEnvironmentProvider>
|
||||||
|
|||||||
@@ -1,23 +1,24 @@
|
|||||||
import { Component, ErrorInfo, ReactNode } from "react";
|
import { Component, ErrorInfo, ReactNode } from "react";
|
||||||
|
import { ErrorPage } from "@/pages/ErrorPage";
|
||||||
|
|
||||||
interface ErrorBoundaryProps {
|
interface ErrorBoundaryProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
fallback: ReactNode;
|
fallback?: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ErrorBoundaryState {
|
interface ErrorBoundaryState {
|
||||||
hasError: boolean;
|
hasError: boolean;
|
||||||
error: Error | undefined;
|
error?: Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
||||||
constructor(props: ErrorBoundaryProps) {
|
constructor(props: ErrorBoundaryProps) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = { hasError: false, error: undefined };
|
this.state = { hasError: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
static getDerivedStateFromError(error: Error): ErrorBoundaryState {
|
||||||
return { hasError: true, error: error };
|
return { hasError: true, error };
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidCatch(error: Error, info: ErrorInfo): void {
|
componentDidCatch(error: Error, info: ErrorInfo): void {
|
||||||
@@ -27,7 +28,10 @@ class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|||||||
|
|
||||||
render(): ReactNode {
|
render(): ReactNode {
|
||||||
if (this.state.hasError) {
|
if (this.state.hasError) {
|
||||||
return this.props.fallback;
|
if (this.props.fallback) {
|
||||||
|
return this.props.fallback;
|
||||||
|
}
|
||||||
|
return <ErrorPage error={this.state.error} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.props.children;
|
return this.props.children;
|
||||||
|
|||||||
Reference in New Issue
Block a user