Chapter 16 · Example 4 · Universal error handling in React
Reusable ErrorBoundary component
A class component with getDerivedStateFromError and componentDidCatch catches render errors anywhere below it, renders a fallback prop, and logs the error.
Loading live editor…