Error Boundaries on Expo

I am using react16 error handling to catch any app Exception and show a fallback UI in case there is an error.
My code is something like this:

class ErrorCatcher extends React.Component {
  constructor(props) {
    super(props)
    this.state = { hasError: false }
  }

  componentDidCatch(error, info) {
    this.setState({ hasError: true });
    Sentry.captureException(error)
  }

  render() {
    if (this.state.hasError) {
      return <Text>Something went wrong.</Text>;
    }
    
    return this.props.children
  }
}

class App extends Component<void, void> {
  render() {
    return (
      <Layout minHeight="100%">
        <ErrorCatcher>
          <RootNavigator />
        </ErrorCatcher>
      </Layout>
    )
  }
}

This code is working just fine in development mode, but once I publish it it is just working for iOS, the Android app sends the exception to Sentry and crashes closing itself instead of showing the fallback UI as the iPhone is properly doing.

I cannot see anything special on the logs except the Exception:

02-12 15:15:10.255 7136-7306/? E/ReactNativeJS: TypeError: undefined is not an object (evaluating 'e.replace')
                                                
                                                This error is located at:
                                                    in FormattedDate
                                                    in RCTText
                                                    in Text
                                                    in FormattedText
                                                    in RCTView
                                                    in SpacerView
                                                    in Unknown
                                                    in RCTView
                                                    in LayoutElement
                                                    in Unknown
                                                    in Unknown
                                                    in Unknown
                                                    in RCTView
                                                    in t
                                                    in RCTView
                                                    in RCTScrollView
                                                    in ScrollView
                                                    in t
                                                    in t
                                                    in RCTView
                                                    in Background
                                                    in RCTView
                                                    in Unknown
                                                    in Unknown
                                                    in RCTView
                                                    in RCTScrollView
                                                    in ScrollView
                                                    in RCTView
                                                    in Background
                                                    in Canvas
                                                    in FlightDetail
                                                    in t
                                                    in t
                                                    in RCTView
                                                    in RCTView
                                                    in RCTView
                                                    in n
                                                    in t
                                                    in n
                                                    in RCTView
                                                    in RCTView
                                                    in t
                                                    in RCTView
                                                    in e
                                                    in r
                                                    in Unknown
                                                    in n
                                                    in n
                                                    in t
                                                    in RCTView
                                                    in LayoutElement
                                                    in Unknown
                                                    in t
                                                    in RCTView
                                                    in t
                                                    in t
                                                    in r
                                                    in RCTView
                                                    in RCTView
                                                    in t
02-12 15:15:10.289 1574-2745/? D/ActivityTrigger: ActivityTrigger activityPauseTrigger 
02-12 15:15:10.296 1574-2745/? I/ActivityManager: START u0 {flg=0xc080000 cmp=host.exp.exponent/.experience.ExperienceActivity (has extras)} from uid 10101 on display 0
02-12 15:15:10.332 7136-7136/? D/h: WARNING: getPackageName called on ScopedContext
02-12 15:15:10.335 7136-7136/? D/h: WARNING: getPackageName called on ScopedContext
02-12 15:15:10.336 7136-7235/? D/h: WARNING: getPackageName called on ScopedContext
02-12 15:15:10.336 1574-2156/? I/MediaFocusControl:  AudioFocus  abandonAudioFocus() from uid/pid 10101/7136 clientId=android.media.AudioManager@ae0a1b0abi23_0_0.host.exp.exponent.modules.api.av.AVModule@65479af
02-12 15:15:10.343 458-2591/? E/ANDR-PERF-MPCTL: Invalid profile no. 0, total profiles 0 only
02-12 15:15:10.377 7136-7248/? D/h: WARNING: getPackageName called on ScopedContext
02-12 15:15:10.385 7136-7136/? W/a: Could not find listener for key: experienceActivityKernelDidLoad
02-12 15:15:10.385 7136-7136/? W/a: Could not find listener for key: openExperienceActivity
02-12 15:15:10.420 14034-14034/? I/GoogleInputMethod: onFinishInput() : Dummy InputConnection bound
02-12 15:15:10.421 14034-14034/? I/GoogleInputMethod: onStartInput() : Dummy InputConnection bound
02-12 15:15:10.443 1574-1594/? I/ActivityManager: Displayed host.exp.exponent/.experience.ExperienceActivity: +98ms
02-12 15:15:10.631 734-734/? I/cnss-daemon: RTM_NEWNEIGH message received: 28
02-12 15:15:10.632 734-734/? E/cnss-daemon: Stale or unreachable neighbors, ndm state: 4

I am using
“expo”: “^23.0.4”,
“react”: “16.0.0”,
“react-native”: “0.50.3”,

Could you try the most minimal example? (without navigators etc., just a simple child)

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.