diff --git a/test/react-native/features/fixtures/app/react_native_navigation_js/index.js b/test/react-native/features/fixtures/app/react_native_navigation_js/index.js index e0cea5ccb1..87e9d736d1 100644 --- a/test/react-native/features/fixtures/app/react_native_navigation_js/index.js +++ b/test/react-native/features/fixtures/app/react_native_navigation_js/index.js @@ -1,137 +1,24 @@ import { Navigation } from 'react-native-navigation' import HomeScreen from './screens/Home' import DetailsScreen from './screens/Details' -import { NativeModules, View, Text, Button, TextInput, StyleSheet } from 'react-native' -import * as React from 'react' -import Bugsnag from '@bugsnag/react-native' -import * as Scenarios from './Scenarios' -import BugsnagReactNativeNavigation from '@bugsnag/plugin-react-native-navigation' -import { Component } from 'react' +import { View, Text, StyleSheet } from 'react-native' +import React, { useEffect } from 'react' +import { launchScenario } from './lib/ScenarioLauncher' -const defaultJsConfig = () => ({ - plugins: [new BugsnagReactNativeNavigation(Navigation)] -}) - -export default class AppScreen extends Component { - constructor (props) { - super(props) - this.state = { - currentScenario: '', - apiKey: '12312312312312312312312312312312', - notifyEndpoint: '', - sessionsEndpoint: '', - scenario: null - } - } - - getConfiguration = () => { - var config = { - apiKey: this.state.apiKey, - autoTrackSessions: false - } - - if (this.state.notifyEndpoint && this.state.sessionsEndpoint) { - config.endpoints = { - notify: this.state.notifyEndpoint, - sessions: this.state.sessionsEndpoint - } - } - return config - } - - setScenario = newScenario => { - this.state.currentScenario = newScenario - } - - clearPersistentData = () => { - NativeModules.BugsnagTestInterface.clearPersistentData() - } +console.reportErrorsAsExceptions = false - startScenario = () => { - console.log(`Running scenario: ${this.state.currentScenario}`) - const scenarioName = this.state.currentScenario - const configuration = this.getConfiguration() - const jsConfig = defaultJsConfig() - const scenario = new Scenarios[scenarioName](configuration, jsConfig) - console.log(` with config: ${JSON.stringify(configuration)} (native) and ${jsConfig} (js)`) - Navigation.setRoot({ - root: { - stack: { - children: [ - { - component: { - name: 'Home' - } - } - ] - } - } - }) - this.state.scenario = scenario - scenario.run() - } +export const AppScreen = () => { + useEffect(() => { + launchScenario() + }, []) - startBugsnag = () => { - console.log(`Starting Bugsnag for scenario: ${this.state.currentScenario}`) - const scenarioName = this.state.currentScenario - const configuration = this.getConfiguration() - const jsConfig = defaultJsConfig() - const scenario = new Scenarios[scenarioName](configuration, jsConfig) - console.log(` with config: ${JSON.stringify(configuration)} (native) and ${jsConfig} (js)`) - NativeModules.BugsnagTestInterface.startBugsnag(configuration) - .then(() => { - Bugsnag.start(jsConfig) - this.state.scenario = scenario - }) - } - - render () { - return ( - - - React Native Navigation Test App - - -