Please describe your new feature request
raygun4reactnative provides RaygunClient.sendError(error) for manually reporting caught errors, but there is no built-in React error boundary component. To report errors caught by an error boundary with full context (including componentStack from componentDidCatch), users have to write their own class-based error boundary and manually wire it up to RaygunClient.
Other crash reporting SDKs ship a dedicated error boundary component that handles this automatically.
Describe the solution you'd like
Provide a RaygunErrorBoundary component that implements componentDidCatch, automatically reports errors to Raygun with the component stack trace, and renders a user-supplied fallback UI:
import { RaygunErrorBoundary } from 'raygun4reactnative';
<RaygunErrorBoundary fallback={<MyErrorScreen />}>
<App />
</RaygunErrorBoundary>
The component would:
- Implement
componentDidCatch(error, errorInfo) and call RaygunClient.sendError() with the error and errorInfo.componentStack as custom data
- Accept a
fallback prop (component or render function) for recovery UI
- Optionally accept an
onError callback for additional handling
Describe alternatives you've considered
Today the workaround is a hand-rolled class component:
class MyErrorBoundary extends Component {
state = { error: undefined };
static getDerivedStateFromError(error: Error) {
return { error };
}
componentDidCatch(error: Error, errorInfo: ErrorInfo) {
RaygunClient.sendError(error);
// componentStack is lost — sendError doesn't accept it
}
render() {
if (this.state.error) return <FallbackUI />;
return this.props.children;
}
}
This works for basic reporting, but sendError doesn't currently accept custom data like the component stack. A first-party component could attach componentStack as structured data on the Raygun error report automatically.
Additional context
This would also pair well with Expo Router. Expo Router's built-in ErrorBoundary export does not implement componentDidCatch (source), so users who want component stack traces in their crash reports need a separate boundary anyway. A RaygunErrorBoundary would fill that gap cleanly.
Please describe your new feature request
raygun4reactnativeprovidesRaygunClient.sendError(error)for manually reporting caught errors, but there is no built-in React error boundary component. To report errors caught by an error boundary with full context (includingcomponentStackfromcomponentDidCatch), users have to write their own class-based error boundary and manually wire it up toRaygunClient.Other crash reporting SDKs ship a dedicated error boundary component that handles this automatically.
Describe the solution you'd like
Provide a
RaygunErrorBoundarycomponent that implementscomponentDidCatch, automatically reports errors to Raygun with the component stack trace, and renders a user-supplied fallback UI:The component would:
componentDidCatch(error, errorInfo)and callRaygunClient.sendError()with the error anderrorInfo.componentStackas custom datafallbackprop (component or render function) for recovery UIonErrorcallback for additional handlingDescribe alternatives you've considered
Today the workaround is a hand-rolled class component:
This works for basic reporting, but
sendErrordoesn't currently accept custom data like the component stack. A first-party component could attachcomponentStackas structured data on the Raygun error report automatically.Additional context
This would also pair well with Expo Router. Expo Router's built-in
ErrorBoundaryexport does not implementcomponentDidCatch(source), so users who want component stack traces in their crash reports need a separate boundary anyway. ARaygunErrorBoundarywould fill that gap cleanly.