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,14 +468,18 @@
// 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
// the Safari Web Inspector console.
if (__DEV__ && originalConsole) {
Object.keys(global.console).forEach(methodName => {
var reactNativeMethod = global.console[methodName];
if (originalConsole[methodName]) {
global.console[methodName] = function() {
originalConsole[methodName](...arguments);
reactNativeMethod.apply(global.console, arguments);
};
}
});
}
}
if (typeof module !== 'undefined') {
module.exports = setupConsole;