Learn how to prevent the 'White Screen of Death' by using Error Boundaries to isolate crashes and keep your production app running smoothly.

An Error Boundary is like a circuit breaker for your UI; it isolates a crash in a single component so the rest of your app stays alive, transforming a total system failure into a localized, manageable issue.
A standard try-catch block is designed for imperative code, such as manually calling a function or fetching data. However, React rendering is declarative; the React engine manages the UI state and reconciliation process for you. If an error occurs while React is determining what the screen should look like, it happens outside of your immediate execution context, meaning a try-catch block will not be able to intercept it. Error Boundaries are specifically designed to bridge this gap by catching errors during the rendering phase, lifecycle methods, and constructors.
Error Boundaries have specific jurisdictions and do not catch errors in four main areas: event handlers (like an onClick function), asynchronous code (such as setTimeout or Promise callbacks), server-side rendering, and errors thrown within the Error Boundary component itself. Because event handlers and async code happen outside of the synchronous rendering flow, React does not automatically unmount the tree when they fail. For these scenarios, developers should continue to use standard try-catch blocks or specialized hooks to manually trigger the boundary.
As of the current version of React, Error Boundaries must be class components because they require the implementation of two specific lifecycle methods: getDerivedStateFromError and componentDidCatch. The first method allows the component to update its state to show a fallback UI, while the second allows for side effects like logging the error to a service. While hooks exist for almost everything else in React, these specific "hero" methods have not yet been implemented for functional components.
Rather than using a single global boundary that wipes out the entire app on failure, developers should use a layered approach. A "Global Safety Net" should exist at the root for catastrophic failures, but "Route Level" boundaries should be placed at major pages to keep navigation functional. Finally, "Feature or Widget Level" boundaries should wrap high-risk or optional components, such as third-party charts or weather widgets. This granular strategy ensures that a localized error only disables a small part of the UI, allowing the user to continue their primary workflow.
To prevent a fallback UI from being a dead end, you can implement a reset mechanism that sets the error state back to false, allowing React to attempt re-rendering the children. This is often done via a "Try Again" button for transient errors like network timeouts. For more persistent bugs, you can use a "Smart Recovery" pattern where the boundary resets automatically when the user navigates to a new URL, often achieved by changing a key prop on the boundary based on the current route.
From Columbia University alumni built in San Francisco
"Instead of endless scrolling, I just hit play on BeFreed. It saves me so much time."
"I never knew where to start with nonfiction—BeFreed’s book lists turned into podcasts gave me a clear path."
"Perfect balance between learning and entertainment. Finished ‘Thinking, Fast and Slow’ on my commute this week."
"Crazy how much I learned while walking the dog. BeFreed = small habits → big gains."
"Reading used to feel like a chore. Now it’s just part of my lifestyle."
"Feels effortless compared to reading. I’ve finished 6 books this month already."
"BeFreed turned my guilty doomscrolling into something that feels productive and inspiring."
"BeFreed turned my commute into learning time. 20-min podcasts are perfect for finishing books I never had time for."
"BeFreed replaced my podcast queue. Imagine Spotify for books — that’s it. 🙌"
"It is great for me to learn something from the book without reading it."
"The themed book list podcasts help me connect ideas across authors—like a guided audio journey."
"Makes me feel smarter every time before going to work"
From Columbia University alumni built in San Francisco
