Don't call originalConsole methods when they don't exist

Reviewed By: @vjeux

Differential Revision: D2485562
This commit is contained in:
Pieter De Baets 2015-09-28 14:58:08 -07:00 committed by facebook-github-bot-4
parent d4f9750e38
commit c74f1e9bc9
1 changed files with 11 additions and 7 deletions

View File

@ -468,13 +468,17 @@
// If available, also call the original `console` method since that is // If available, also call the original `console` method since that is
// sometimes useful. Ex: on OS X, this will let you see rich output in // sometimes useful. Ex: on OS X, this will let you see rich output in
// the Safari Web Inspector console. // the Safari Web Inspector console.
Object.keys(global.console).forEach(methodName => { if (__DEV__ && originalConsole) {
var reactNativeMethod = global.console[methodName]; Object.keys(global.console).forEach(methodName => {
global.console[methodName] = function() { var reactNativeMethod = global.console[methodName];
originalConsole[methodName](...arguments); if (originalConsole[methodName]) {
reactNativeMethod.apply(global.console, arguments); global.console[methodName] = function() {
}; originalConsole[methodName](...arguments);
}); reactNativeMethod.apply(global.console, arguments);
};
}
});
}
} }
if (typeof module !== 'undefined') { if (typeof module !== 'undefined') {