클래스형 컴포넌트로 구현
class ErrorBoundary extends React.Component<Props, State>
getDerivedStateFromError
대체 UI 표시
componentDidCatch
상세 에러 정보 기록
→ 혹은 react-error-boundary
라이브러리 설치
const handleClick = () => {
throw Error (..)
}
// Error Boundary가 포착 X
const [error, setError] = useState();
if (error) throw error; // React 렌더링 과정에서 throw
fetch.. = async() => {
try { ... }
catch { setError(true); }
}