Error Boundaries

Chris Minnick · 2022

Even if it were possible to write perfect code, the nature of interactive web applications guarantees that once in a while something is going to break. Error boundaries will help the reader ensure that when something goes wrong, it won’t result in the user seeing a crashed user interface. Both error handling and logging are enabled and simplified in React through the use of error boundaries. An error boundary is a component that catches errors that happen in its child components. This chapter explains how to write error boundary, use an error boundary to display a fallback UI, use an error boundary to log errors to a logging service, use the react-error-boundary package, catch errors using try/catch, and use react-error-boundary’s useErrorHandler hook.

Read the paper · More papers on PaperTik