/**
* Sample React Native App
* https://github.com/facebook/react-native
*
* @format
* @flow strict-local
*/
import React from 'react';
import {
Button,
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import { NativeModules } from 'react-native';
// Setup Bugsnag client to capture errors automatically
import Bugsnag from '@bugsnag/react-native'
Bugsnag.start();
function triggerException() {
bogusFunction(); // eslint-disable-line no-undef
}
function triggerHandledException() {
bogusHandledFunction(); // eslint-disable-line no-undef
}
async function triggerPromiseRejection() {
try {
await NativeModules.CrashyCrashy.generatePromiseRejection();
} catch (e) {
Bugsnag.notify(e)
}
}
function triggerNativeException() {
NativeModules.CrashyCrashy.generateCrash()
}
function triggerNativeHandledError() {
NativeModules.CrashyCrashy.handledError()
}
const App: () => React$Node = () => {
return (
<>
{global.HermesInternal == null ? null : (
Engine: Hermes
)}
Press the buttons below to test examples of Bugsnag functionality. Make sure you have changed the API key in Info.plist or AndroidManifest.xml.
Tap this button to send a JS crash to Bugsnag
Tap this button to send a native {Platform.OS} crash to Bugsnag
>
);
};
const styles = StyleSheet.create({
container: {
flex: 1,
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#eeeeee',
},
buttonContainer: {
margin: 20
},
info: {
textAlign: 'center',
color: '#666',
fontSize: 11,
marginBottom: 20
}
})
export default App;