Skip to content
Permalink
056c6b84f3
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
44 lines (38 sloc) 1.11 KB
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>
</>
);
}
}