From 5a0bd3c164d3ed04b3b3d33e1504eb87d52b6cdf Mon Sep 17 00:00:00 2001 From: Christopher Hogan Date: Thu, 31 Oct 2019 09:54:07 -0700 Subject: [PATCH 1/2] console.assert doesn't exist in the simulator, so this will always redbox unless the debugger is attached (in which case it runs through chrome which has all the console methods already defined) --- Libraries/polyfills/console.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/polyfills/console.js b/Libraries/polyfills/console.js index e6f53787f5d653..8032c5d4169392 100644 --- a/Libraries/polyfills/console.js +++ b/Libraries/polyfills/console.js @@ -559,13 +559,13 @@ if (global.nativeLoggingHook) { console[methodName] = function() { // TODO(T43930203): remove this special case once originalConsole.assert properly checks // the condition - if (methodName === 'assert') { - if (!arguments[0]) { - originalConsole.assert(...arguments); - } - } else { + // if (methodName === 'assert') { + // if (!arguments[0]) { + // originalConsole.assert(...arguments); + // } + // } else { originalConsole[methodName](...arguments); - } + // } reactNativeMethod.apply(console, arguments); }; } From 9ee960623e5b6b5bc446e7e47efbee8d6b99b187 Mon Sep 17 00:00:00 2001 From: Christopher Hogan Date: Thu, 31 Oct 2019 10:06:16 -0700 Subject: [PATCH 2/2] a more proper fix is to check that console has the assert property --- Libraries/polyfills/console.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Libraries/polyfills/console.js b/Libraries/polyfills/console.js index 8032c5d4169392..de76df6e3bb2be 100644 --- a/Libraries/polyfills/console.js +++ b/Libraries/polyfills/console.js @@ -559,13 +559,13 @@ if (global.nativeLoggingHook) { console[methodName] = function() { // TODO(T43930203): remove this special case once originalConsole.assert properly checks // the condition - // if (methodName === 'assert') { - // if (!arguments[0]) { - // originalConsole.assert(...arguments); - // } - // } else { + if (methodName === 'assert') { + if (!arguments[0] && originalConsole.hasOwnProperty('assert')) { + originalConsole.assert(...arguments); + } + } else { originalConsole[methodName](...arguments); - // } + } reactNativeMethod.apply(console, arguments); }; }