In this lesson, you will learn why React’s built-in Error Boundaries are powerful for managing JavaScript bugs but completely powerless against crashes occurring in the Native layer.
The JavaScript Safety Net
In React, we use Error Boundaries to catch errors that occur during rendering, in lifecycle methods, or in constructors of the component tree. If a component throws an error, the boundary catches it and allows you to display a fallback UI instead of crashing the entire app. You likely use them like this:
<ErrorBoundary fallback={<Text>Something went wrong!</Text>}>
<MyComponent />
</ErrorBoundary>
This works perfectly for logic errors, such as trying to access a property of undefined inside your JavaScript code.
The Native Wall
The crucial limitation here is that Error Boundaries live entirely within the JavaScript thread. They are essentially a try/catch block for React component logic.
However, React Native apps rely on the bridge to communicate with native code (like the UI Manager or Native Modules you've learned about previously). If an error occurs on the native side—such as a segmentation fault in a custom native module, a threading conflict, or a failure in the underlying UI Manager when rendering a component—the JavaScript engine often isn't even aware the error is happening until it is too late.
When a native crash occurs, the "process" of your application effectively dies or is killed by the operating system. Because the app process itself is being terminated, your JavaScript-based Error Boundary has no opportunity to run, "catch" the error, or render a fallback UI. It is like trying to catch a falling glass with a net that is attached to the glass itself; if the glass shatters into the ground, the net goes with it.
For native-side issues, React’s built-in tools cannot prevent the app from closing. Instead, you must rely on native-level monitoring tools (like Sentry or Firebase Crashlytics) that track crashes at the OS level to diagnose these "hard" failures.
Key Takeaway: Error Boundaries only catch JavaScript runtime exceptions; they cannot prevent the application from closing when an error originates in the native layer.