React Native – Error handler (2)

Bugsnag

Issue

  • createBoundary() undefined in Debug mode

Install Bugsnag

react-native/#installation

import { ErrorView } from 'src/components'
import Bugsnag from '@bugsnag/react-native';

Bugsnag.start();

const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);

const App = () => {
  ...
}

export default () => (
  <ErrorBoundary FallbackComponent={ErrorView}>
    <App />
  </ErrorBoundary>
);

Notify error for try/ catch

      try {
        const response = await fetchData( ... );
      } catch (error) {
        Bugsnag.notify(error);
      }

Notify message with data and type (not for free plan(?))

var metadata = {
  from: 'moka',
  to: 'french press'
}
Bugsnag.leaveBreadcrumb('Preference updated', metadata, 'state')
// types: 'navigation', 'request', 'process', 'log', 'user', 'state', 'error', 'manual'

Be the first to comment

Leave a Reply

Your email address will not be published.


*