1.1.1 • Published 5 years ago

rn-global-error-handler v1.1.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

rn-global-error-handler

React Native error handler for unhandled exception

NPM JavaScript Style Guide

Build Status

Install

npm install --save rn-global-error-handler

Usage

Bare minimum

Extend your top level component from SafeComponent. This shows a popup whenever an unhandled exception airses and doesn't kill the app.

import { Text } from "react-native";
import SafeComponent from "rn-global-error-handler";

class App extends SafeComponent {
  constructor(){
    super();
  }

  render(){
    return <Text>Cool App!</Text>
  }  
}

export default App;

Functional

Compopse your top level component with "safe" function. This shows a popup whenever an unhandled exception airses and doesn't kill the app.

With top level class component

import { Text } from "react-native";
import {safe} from "rn-global-error-handler";

class App extends SafeComponent {
  constructor(){
    super();
  }

  render(){
    return <Text>Cool App!</Text>
  }  
}

export default safe(App);

With top level functional component

const App = () => {
  return <Text>Cool App!</Text>
}

export default safe(App);

Enable in dev environment

const App = () => {
  return <Text>Cool App!</Text>
}

export default safe(App,true);

with custom error handler

function customErrHandler() {
  // log error message
  alert("This is a custom error handler");
}

const App = () => {
  return <Text>Cool App!</Text>
}

export default safe(App,true,customErrHandler);

License

MIT © mujib517

1.1.1

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.1.2

5 years ago

1.1.0

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago