/** * src/book/BookErrorBoundary.tsx * * Simple class-based error boundary for the /book section. * Prevents a rendering error anywhere in the book from collapsing the * entire React tree and showing just the dark body background. */ import { Component, type ReactNode, type ErrorInfo } from 'react'; interface Props { children: ReactNode; } interface State { error: Error | null; } export class BookErrorBoundary extends Component { state: State = { error: null }; static getDerivedStateFromError(error: Error): State { return { error }; } componentDidCatch(error: Error, info: ErrorInfo) { // Log to console so it's visible in devtools without crashing console.error('[Book] Uncaught error:', error, info.componentStack); } render() { if (this.state.error) { return (

Something went wrong

            {this.state.error.message}
          
); } return this.props.children; } }