How to Detect Crashes in a React Native App


Spencer Carli

Developer, cat dad, and devout pizza lover. Teaching at React Native School and building apps with Handlebar Labs.

Last Updated: March 6, 2019

In this lesson we learn how to handle errors in production. I would suggest checking out react-native-exception-handler as a way to get started with capture errors in all runtimes of React Native.

If you're ready to go one step further I highly suggest taking a look at Instabug. Instabug provides a platform and tooling to capture and analyze errors in your React Native app, in addition to other things (like capturing user feedback).

They've graciously sponsored the production of an entire class about debugging React Native apps so everyone can access it. You can access the course, How to Debug React Native Apps in Development and Production here on React Native School.

Commands and code from the lesson:


yarn add react-native-exception-handler
react-native link react-native-exception-handler


import React from 'react';
import { View, Button } from 'react-native';
import {
} from 'react-native-exception-handler';

const handleError = (error, isFatal) => {
  // fetch
  console.log(error, isFatal);

setJSExceptionHandler((error, isFatal) => {
  console.log('caught global error');
  handleError(error, isFatal);
}, true);

setNativeExceptionHandler((errorString) => {
  // do the things

export default class App extends React.Component {
  state = {
    number: 0,

  makeRequest = () => {
      .then((res) => res.json())
      .then((res) => {
      .catch((error) => {
        handleError(error, false);

  badStateChange = () => {
    this.setState((state) => ({
      number: + 1,

  render() {
    return (
          flex: 1,
          backgroundColor: '#fff',
          alignItems: 'center',
          justifyContent: 'center',
        <Button title="Make an invalid request" onPress={this.makeRequest} />
        <Button title="Bad state change" onPress={this.badStateChange} />
React Native School Logo

React Native School

Want to further level up as a React Native developer? Join React Native School! You'll get access to all of our classes and our private Slack community.