项目作者: cwhenderson20

项目描述 :
Deliberately crash your app. Good for testing crash reporting services.
高级语言: Java
项目地址: git://github.com/cwhenderson20/react-native-crash-tester.git
创建时间: 2021-06-01T23:16:48Z
项目社区:https://github.com/cwhenderson20/react-native-crash-tester

开源协议:MIT License

下载


react-native-crash-tester

Deliberately crash your app. Good for testing crash reporting services.

Installation

  1. npm install react-native-crash-tester

or

  1. yarn add react-native-crash-tester

Usage

Trigger a Native Crash

  1. import CrashTester from 'react-native-crash-tester';
  2. CrashTester.nativeCrash();
  3. CrashTester.nativeCrash('Custom message!');

Trigger a JavaScript Crash

  1. import CrashTester from 'react-native-crash-tester';
  2. CrashTester.jsCrash();
  3. CrashTester.jsCrash('Custom message!');

Test a React Error Boundary

  1. import * as React from 'react';
  2. import { Button } from 'react-native';
  3. import { CrashingComponent } from 'react-native-crash-tester';
  4. import ErrorBoundary from './MyErrorBoundary';
  5. function TestComponent() {
  6. const [shown, setShown] = React.useState(false);
  7. <ErrorBoundary>
  8. <Button title="Crash" onPress={() => setShown(true)} />
  9. {shown && <CrashingComponent ></CrashingComponent>}
  10. </ErrorBoundary>;
  11. }

You can run the app in ./example to see sample usage.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT