Make console override detectable (for RN YellowBox)

This commit is contained in:
Brian Vaughn 2019-07-20 08:05:08 -07:00
parent 167daf7a4a
commit 33da657178
1 changed files with 6 additions and 2 deletions

View File

@ -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) {}
});
}