From 9bf82fde25755296d93b67f75ec464f936973d71 Mon Sep 17 00:00:00 2001 From: Dave Coates Date: Sat, 12 Sep 2015 16:41:00 +1000 Subject: [PATCH] Don't trigger react-native error handler react-native captures console.error calls and displays it's own exception handler. This behaviour can be disabled by setting console.reportErrorsAsExceptions to false. Add check for this flag and temporarily disable it. --- src/development.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/development.js b/src/development.js index c8516d5..cfeb0a0 100644 --- a/src/development.js +++ b/src/development.js @@ -13,7 +13,15 @@ export default function catchErrors({ filename, components, imports }) { try { return originalRender.apply(this, arguments); } catch (err) { - console.error(err); + if (console.reportErrorsAsExceptions) { + // Stop react-native from triggering it's own error handler + console.reportErrorsAsExceptions = false; + console.error(err); + // Reactivate it so other errors are still handled + console.reportErrorsAsExceptions = true; + } else { + console.error(err); + } return React.createElement(ErrorReporter, { error: err });