Error Boundaries

Error Boundaries

I've already covered error boundaries as part of the code splitting section which shows a neat example. But in summary, these are a React way of catching errors anywhere in a component tree, logging these and displaying fallback interfaces. These errors can be caught during render, in lifecycle methods, and in constructors (for class based components).

Components become an error boundary if they have either getDerivedStateFromError() or componentDidCatch(). It's worth noting that error boundaries do not catch errors inside of event handlers.