Error Boundaries as a Pattern
Learn how error boundary components catch rendering errors in their subtree and display a fallback UI instead of crashing the whole app.
An error boundary is a component that catches JavaScript errors thrown during rendering, in lifecycle methods, and in constructors anywhere in its child tree, logs them, and displays a fallback UI instead of letting the error crash and unmount the entire application. Without one, an uncaught render error anywhere in the tree unmounts the whole React tree, showing a blank page.
An error boundary is like a ship's bulkhead doors: if one compartment (a subtree) floods due to a hull breach (a render error), sealing that section off keeps the rest of the ship (the rest of the app) afloat and functioning, instead of the whole vessel going down.