error boundary

A class component that catches errors thrown while rendering its children and shows a fallback UI instead of crashing the whole app.

In more detail

It uses static getDerivedStateFromError to switch to the fallback and componentDidCatch to report the error. It does not catch errors in event handlers, in asynchronous code such as timers, in server rendering or in itself. Changing its key, or resetting its state, lets the user retry.

Related terms

Taught in

References