Files
app
components
AppealBans.tsx
AppealCard.tsx
Fallback.tsx
Forbidden.tsx
FormGenerator.tsx
GameAppealCard.tsx
GameModManagementModal.tsx
InactivityNoticeCard.tsx
Login.tsx
Navigation.tsx
NewAppealBan.tsx
NewGameBan.tsx
NewInactivityNotice.tsx
NewInfractionModal.tsx
NoJSAlert.tsx
ReportCard.tsx
Success.tsx
data
functions
public
.gitignore
.node-version
.prettierignore
OFL.txt
README.md
emotion-server.js
index.css
index.d.ts
package-lock.json
package.json
remix.config.js
server.ts
theme.ts
tsconfig.json
car-crushers-portal/components/Fallback.tsx
2023-10-19 16:49:09 -04:00

45 lines
1.1 KiB
TypeScript

import { Component, type ReactNode } from "react";
import Navigation from "./Navigation.js";
import { Code, Container, Heading, Text } from "@chakra-ui/react";
interface ErrorState {
error: string | null;
errored: boolean;
}
type Props = {
[k: string]: any;
children: ReactNode;
};
export default class Fallback extends Component<Props, ErrorState> {
constructor(props: Props) {
super(props);
this.state = { error: null, errored: false };
}
static getDerivedStateFromError(error: Error) {
return { error, errored: true };
}
render() {
if (!this.state.errored) return this.props.children;
return (
<>
<Navigation />
<Container maxW="container.xl" pb="100px">
<Heading>Oops! Something broke.</Heading>
<Text fontSize="xl">See the details below</Text>
<br />
<Text>{this.state.error?.toString()}</Text>
</Container>
<Container maxW="container.xl">
{/* @ts-expect-error The stack property should always exist */}
<Code>{this.state.error.stack}</Code>
</Container>
</>
);
}
}