getDerivedStateFromError
A static class method React calls after a child throws during rendering, returning new state so the boundary renders its fallback.
In more detail
It must be pure and only return state, such as { hasError: true }; do logging in componentDidCatch instead. React calls it during rendering, before the fallback is committed to the page.
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.
- 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.
- static property — A property attached to a function or class itself rather than to its instances, such as Tabs.Item.
Taught in
- Error Boundaries: componentDidCatch And Fallback UI Trees — React 19 & Modern Component Architecture