Home

Awesome

react-native-promise-rejection-utils

npm version Dependency Status devDependencies Status npm

Utils for global tracking of unhandled promise rejections.

Installation

$ npm i react-native-promise-rejection-utils

Usage

import {
  getUnhandledPromiseRejectionTracker,
  setUnhandledPromiseRejectionTracker,
} from 'react-native-promise-rejection-utils'

const prevTracker = getUnhandledPromiseRejectionTracker()

setUnhandledPromiseRejectionTracker((id, error) => {
  console.warn('Unhandled promise rejection!', id, error)

  if (prevTracker !== undefined) {
    prevTracker(id, error)
  }
})