Skip to content

Commit 066d0fd

Browse files
authored
Merge pull request #7099 from StoDevX/drew/sentry-init
guard against registering the sentry nav container in dev
2 parents 107ee6b + 6c52216 commit 066d0fd

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

source/app.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {NavigationContainer} from '@react-navigation/native'
2222

2323
import {RootStack} from './navigation'
2424
import {LoadingView} from '@frogpond/notice'
25+
import {IS_PRODUCTION} from '@frogpond/constants'
2526
import {StatusBar, useColorScheme} from 'react-native'
2627

2728
export default function App(): JSX.Element {
@@ -31,6 +32,15 @@ export default function App(): JSX.Element {
3132
const theme = scheme === 'dark' ? CombinedDarkTheme : CombinedLightTheme
3233
const statusBarStyle = scheme === 'dark' ? 'light-content' : 'dark-content'
3334

35+
const registerContainer = () => {
36+
if (!IS_PRODUCTION) {
37+
return
38+
}
39+
40+
// Register the navigation container with the instrumentation
41+
sentryInit.routingInstrumentation.registerNavigationContainer(navigationRef)
42+
}
43+
3444
return (
3545
<ReduxProvider store={store}>
3646
<PersistGate
@@ -43,15 +53,7 @@ export default function App(): JSX.Element {
4353
>
4454
<PaperProvider theme={theme}>
4555
<ActionSheetProvider>
46-
<NavigationContainer
47-
onReady={() => {
48-
// Register the navigation container with the instrumentation
49-
sentryInit.routingInstrumentation.registerNavigationContainer(
50-
navigationRef,
51-
)
52-
}}
53-
theme={theme}
54-
>
56+
<NavigationContainer onReady={registerContainer} theme={theme}>
5557
<StatusBar barStyle={statusBarStyle} />
5658
<RootStack />
5759
</NavigationContainer>

0 commit comments

Comments
 (0)