Skip to content

Commit

Permalink
add setAppState to react-navigation-native-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
AnastasiiaSvietlova committed Jan 14, 2025
1 parent df754e7 commit 355fe96
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,20 @@ import type { Plugin, SpanFactory } from '@bugsnag/core-performance'
import type { ReactNativeConfiguration } from '@bugsnag/react-native-performance'
import { NavigationContainer } from '@react-navigation/native'
import { createNavigationContainer } from './create-navigation-container'
import type { AppState } from '../../core/lib/core'

class BugsnagPluginReactNavigationNativePerformance implements Plugin<ReactNativeConfiguration> {
private spanFactory?: SpanFactory<ReactNativeConfiguration>
private setAppState?: (appState: AppState) => void

configure (_configuration: ReactNativeConfiguration, spanFactory: SpanFactory<ReactNativeConfiguration>) {
configure (_configuration: ReactNativeConfiguration, spanFactory: SpanFactory<ReactNativeConfiguration>, setAppState: (appState: AppState) => void) {
this.spanFactory = spanFactory
this.setAppState = setAppState
}

createNavigationContainer = (Container = NavigationContainer) => {
if (!this.spanFactory) throw new Error('Bugsnag: BugsnagPluginReactNavigationNativePerformance not configured')
return createNavigationContainer(Container, this.spanFactory) as typeof Container
if (!this.spanFactory || !this.setAppState) throw new Error('Bugsnag: BugsnagPluginReactNavigationNativePerformance not configured')
return createNavigationContainer(Container, this.spanFactory, this.setAppState) as typeof Container
}
}

Expand Down

0 comments on commit 355fe96

Please sign in to comment.