
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-native-comprehensive-error-handler
Advanced tools
Comprehensive error handling for React Native - catches render, sync, and async errors with multi-engine support (Hermes, JSC, Web)
Comprehensive error handling for React Native - catches render, sync, and async errors with multi-engine support
A robust, production-ready error handling solution that catches all error types in React Native apps:
npm install react-native-comprehensive-error-handler react-native-safe-area-context
npx expo install react-native-comprehensive-error-handler react-native-safe-area-context
💡 Note: With npm 7+, peer dependencies install automatically. The above command will install both packages in one go.
Wrap your app with GlobalErrorBoundary:
import { GlobalErrorBoundary } from 'react-native-comprehensive-error-handler';
function App() {
return (
<GlobalErrorBoundary
onError={(error, errorType, errorInfo) => {
console.log('Error caught:', error);
// Optional: Send to your error reporting service
}}
>
<YourApp />
</GlobalErrorBoundary>
);
}
That's it! 🎉 All errors are now caught and handled gracefully.
<GlobalErrorBoundary>The main component that wraps your app and handles all errors.
| Prop | Type | Required | Default | Description |
|---|---|---|---|---|
children | ReactNode | ✅ | - | Your app content |
config | GlobalErrorBoundaryConfig | ❌ | See below | Error handling configuration |
onError | (error, errorType, errorInfo) => void | ❌ | - | Callback when error is caught |
fallbackComponent | ComponentType<FallbackComponentProps> | ❌ | DefaultFallback | Custom error UI |
{
enableRenderErrors: true, // Catch React render errors
enableSyncErrors: true, // Catch synchronous JS errors
enableAsyncErrors: true, // Catch async/promise errors
suppressDefaultHandler: true // Suppress red screen in dev
}
<GlobalErrorBoundary
config={{
enableRenderErrors: true,
enableSyncErrors: true,
enableAsyncErrors: true,
suppressDefaultHandler: true
}}
onError={(error, errorType, errorInfo) => {
// Your error handling logic
if (__DEV__) {
console.log(error);
} else {
// Send to Sentry, Firebase, etc.
yourErrorService.report(error);
}
}}
>
<App />
</GlobalErrorBoundary>
Provide your own error screen:
import { FallbackComponentProps } from 'react-native-comprehensive-error-handler';
function CustomErrorScreen({ error, errorType, errorInfo, resetError }: FallbackComponentProps) {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Oops! Something went wrong</Text>
<Text>{error.message}</Text>
<Button title="Try Again" onPress={resetError} />
</View>
);
}
<GlobalErrorBoundary fallbackComponent={CustomErrorScreen}>
<App />
</GlobalErrorBoundary>
Use a ref to reset errors programmatically:
import { useRef } from 'react';
import { GlobalErrorBoundary, GlobalErrorBoundaryRef } from 'react-native-comprehensive-error-handler';
function App() {
const errorBoundaryRef = useRef<GlobalErrorBoundaryRef>(null);
const handleReset = () => {
errorBoundaryRef.current?.resetError();
};
const checkError = () => {
const currentError = errorBoundaryRef.current?.getCurrentError();
if (currentError) {
console.log('Current error:', currentError);
}
};
return (
<GlobalErrorBoundary ref={errorBoundaryRef}>
<App />
</GlobalErrorBoundary>
);
}
Test different error types to verify error handling:
// Render error
const ThrowRenderError = () => {
throw new Error('Test render error');
return null;
};
// Sync error
const throwSyncError = () => {
throw new Error('Test sync error');
};
// Async error
const throwAsyncError = async () => {
await Promise.reject(new Error('Test async error'));
};
| Platform | Render Errors | Sync Errors | Async Errors |
|---|---|---|---|
| iOS (Hermes) | ✅ | ✅ | ✅ |
| iOS (JSC) | ✅ | ✅ | ✅ |
| Android (Hermes) | ✅ | ✅ | ✅ |
| Android (JSC) | ✅ | ✅ | ✅ |
| Web | ✅ | ⚠️* | ✅ |
| Expo | ✅ | ✅ | ✅ |
*Web sync errors are logged but may not trigger fallback UI due to browser behavior.
Full TypeScript definitions included:
import {
GlobalErrorBoundary,
GlobalErrorBoundaryProps,
GlobalErrorBoundaryConfig,
GlobalErrorBoundaryRef,
FallbackComponentProps,
ErrorType,
ErrorState,
JSEngine,
} from 'react-native-comprehensive-error-handler';
┌────────────────────────────────────────────┐
│ GlobalErrorBoundary │
└───────┬──────────────┬─────────────┬───────┘
│ │ │
┌────▼────┐ ┌────▼───┐ ┌────▼────────┐
│ Render │ │ Sync │ │ Async │
│ Error │ │ Error │ │ Error │
└────┬────┘ └───┬────┘ └────┬────────┘
│ │ │
┌────▼────────┐ ┌──▼─────────┐ ┌──▼───────────┐
│ React │ │ ErrorUtils │ │ Promise │
│ Boundary │ │ │ │ Tracker │
│ │ │ │ │(Multi-Engine)│
└─────────────┘ └────────────┘ └──────────────┘
Automatically detects and uses the appropriate promise rejection tracking:
HermesInternal.enablePromiseRejectionTrackerpromise/setimmediate/rejection-tracking modulewindow.unhandledrejection eventA: No! This package works perfectly with Expo without any configuration.
A: No, this only catches JavaScript errors. Native crashes require platform-specific crash reporting tools.
A: Minimal. Error handlers are lightweight and only active when errors occur.
A: Yes! Use the config prop to disable any error type you don't want to catch.
A: Yes! Simply check the error in your onError callback and decide whether to report it or not. You can also call resetError() immediately for errors you want to dismiss.
Contributions are welcome! Please open an issue or submit a pull request.
MIT © Vikas Reddy
Made with ❤️ for the React Native community
FAQs
Comprehensive error handling for React Native - catches render, sync, and async errors with multi-engine support (Hermes, JSC, Web)
The npm package react-native-comprehensive-error-handler receives a total of 0 weekly downloads. As such, react-native-comprehensive-error-handler popularity was classified as not popular.
We found that react-native-comprehensive-error-handler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.