Skip to content

Error Boundary

<PionneErrorBoundary> is a React Error Boundary that:

  1. Catches errors bubbling up from its children.
  2. Sends the event to Pionne with mechanism: { type: 'react', handled: true }.
  3. Shows a fallback UI instead of the crashed sub-tree.
import { PionneErrorBoundary } from '@pionne/react-native';
import { View, Text } from 'react-native';
export default function App() {
return (
<PionneErrorBoundary fallback={<Text>Something crashed</Text>}>
<MainNavigator />
</PionneErrorBoundary>
);
}
PropTypeDescription
fallbackReactNode | (info) => ReactNodeUI shown on error
tagsRecord<string, unknown>?Tags added to the event
onError(err, info) => voidHook called after capture
<PionneErrorBoundary
tags={{ boundary: 'root' }}
fallback={({ error, reset }) => (
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
<Text>Error: {error.message}</Text>
<Button title="Retry" onPress={reset} />
</View>
)}
onError={(err) => console.log('Boundary triggered', err)}
>
<CheckoutFlow />
</PionneErrorBoundary>

reset() resets the boundary’s internal state and tries to render its children again.

You can nest several boundaries to isolate failures:

<PionneErrorBoundary fallback={<RootFallback />} tags={{ boundary: 'root' }}>
<Header />
<PionneErrorBoundary fallback={<FeedFallback />} tags={{ boundary: 'feed' }}>
<Feed />
</PionneErrorBoundary>
<Footer />
</PionneErrorBoundary>

If <Feed /> crashes, the header and footer keep working.

CaseBoundaryAuto-capture
React render (return <Bad/>)YesNo
Async useEffectNoYes (Hermes)
onPress handlerNoYes (timer/global)
Error in a timerNoYes