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

Taught in

References