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.props.title} {this.state.error?.message || "An unexpected error occurred"}
            {this.state.error?.stack}
          
); } return this.props.children; } } const StyledHeading = styled("h1")<{ className?: string }>` font-size: 1.125rem; font-weight: 500; color: var(--j-text-color-strong); `;