'use client'; import { Component, ReactNode } from 'react'; interface Props { children: ReactNode; fallback?: string; } interface State { hasError: boolean; error: Error | null; } export default class ErrorBoundary extends Component { constructor(props: Props) { super(props); this.state = { hasError: false, error: null }; } static getDerivedStateFromError(error: Error): State { return { hasError: true, error }; } render() { if (this.state.hasError) { return (

{this.props.fallback || '컴포넌트 렌더링 오류'}

{this.state.error?.message}

{this.state.error?.stack}
); } return this.props.children; } }