I have a React Native application and sometimes instead of rendering components it shows just white screen. There are no errors or exceptions, it just as empty DOM.
This error appears both for Android and iOS and I can't catch any pattern when it happens. Can BugSnag or Crashlytics give me some more info which can help? Are there any way to treat white screen like an error in these services?
The best way to capture white screen errors in React Native using Bugsnag would be with error boundaries. You can find a great article about it here: https://medium.com/wix-engineering/white-screen-of-death-how-to-handle-errors-in-react-native-4d57ac82b6d8
In your custom error boundary, inside the componentDidCatch
, you can notify Bugsnag using Bugsnag.notify(error)
.
From now on, if a JS error is thrown from your component (e.g. white screen error), the error boundary will catch it, and log the error to Bugsnag.