Make console override detectable (for RN YellowBox)
Brian Vaughn committed
Jul 20, 2019 at 08:05 UTC
33da657178159702c5e08c4634e062f992019208
1 file changed
+6
-2
src/backend/console.js
+6
-2
@@ -82,8 +82,7 @@ export function patch(): void {
82
const originalMethod = (originalConsoleMethods[method] =
83
targetConsole[method]);
84
85
- // $FlowFixMe property error|warn is not writable.
86
- targetConsole[method] = (...args) => {
85
+ const overrideMethod = (...args) => {
86
// If we are ever called with a string that already has a component stack, e.g. a React error/warning,
87
// don't append a second stack.
88
const alreadyHasComponentStack =
@@ -122,6 +121,11 @@ export function patch(): void {
121
122
originalMethod(...args);
123
};
124
+
125
+ overrideMethod.__REACT_DEVTOOLS_ORIGINAL_METHOD__ = originalMethod;
126
+
127
+ // $FlowFixMe property error|warn is not writable.
128
+ targetConsole[method] = overrideMethod;
129
} catch (error) {}
130
});
131
}