componentDidCatch
A class lifecycle method React calls after a child error, receiving the error and an info object whose componentStack shows which components were rendering.
In more detail
Use it to send the error to a logging or monitoring service. It runs after the fallback has been committed.
Related terms
- error boundary — A class component that catches errors thrown while rendering its children and shows a fallback UI instead of crashing the whole app.
- getDerivedStateFromError — A static class method React calls after a child throws during rendering, returning new state so the boundary renders its fallback.
- telemetry — The data a running system sends out about itself, such as logs, metrics and traces.
- stack trace — The list of function calls that were running when an error happened, printed to help a developer find where it came from; Python calls it a traceback.
Taught in
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture