From 33da657178159702c5e08c4634e062f992019208 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Sat, 20 Jul 2019 08:05:08 -0700 Subject: [PATCH] Make console override detectable (for RN YellowBox) --- src/backend/console.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/backend/console.js b/src/backend/console.js index aa5510a211..1b89ce782d 100644 --- a/src/backend/console.js +++ b/src/backend/console.js @@ -82,8 +82,7 @@ export function patch(): void { const originalMethod = (originalConsoleMethods[method] = targetConsole[method]); - // $FlowFixMe property error|warn is not writable. - targetConsole[method] = (...args) => { + const overrideMethod = (...args) => { // If we are ever called with a string that already has a component stack, e.g. a React error/warning, // don't append a second stack. const alreadyHasComponentStack = @@ -122,6 +121,11 @@ export function patch(): void { originalMethod(...args); }; + + overrideMethod.__REACT_DEVTOOLS_ORIGINAL_METHOD__ = originalMethod; + + // $FlowFixMe property error|warn is not writable. + targetConsole[method] = overrideMethod; } catch (error) {} }); }