import React from "react"; import { Text } from "./text"; import { styled } from "goober"; interface ErrorBoundaryState { hasError: boolean; error?: Error; } export class ErrorBoundary extends React.Component< { children: React.ReactNode; title: string }, ErrorBoundaryState > { constructor(props: { children: React.ReactNode; title: string }) { super(props); this.state = { hasError: false }; } static getDerivedStateFromError(error: Error): ErrorBoundaryState { return { hasError: true, error }; } componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void { console.error(error); } render() { if (this.state.hasError) { return (
{this.state.error?.stack}