Skip to content

Commit 7de2f77

Browse files
shenjunrufacebook-github-bot
authored andcommitted
Fix expose originalConsole issue (#22844)
Summary: The "originalConsole" expose is incorrect in the "polyfills/console.js" Changelog: ---------- [GENERAL] [Fixed] - Fixed originalConsole expose issue Pull Request resolved: #22844 Differential Revision: D13579480 Pulled By: cpojer fbshipit-source-id: 1d3ad84d3560b757df23170924af9c7655738871
1 parent 2b883ab commit 7de2f77

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

Libraries/polyfills/console.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,14 @@ function consoleGroupEndPolyfill() {
516516

517517
if (global.nativeLoggingHook) {
518518
const originalConsole = global.console;
519+
// Preserve the original `console` as `originalConsole`
520+
if (__DEV__ && originalConsole) {
521+
const descriptor = Object.getOwnPropertyDescriptor(global, 'console');
522+
if (descriptor) {
523+
Object.defineProperty(global, 'originalConsole', descriptor);
524+
}
525+
}
526+
519527
global.console = {
520528
error: getNativeLogFunction(LOG_LEVELS.error),
521529
info: getNativeLogFunction(LOG_LEVELS.info),
@@ -532,12 +540,6 @@ if (global.nativeLoggingHook) {
532540
// sometimes useful. Ex: on OS X, this will let you see rich output in
533541
// the Safari Web Inspector console.
534542
if (__DEV__ && originalConsole) {
535-
// Preserve the original `console` as `originalConsole`
536-
const descriptor = Object.getOwnPropertyDescriptor(global, 'console');
537-
if (descriptor) {
538-
Object.defineProperty(global, 'originalConsole', descriptor);
539-
}
540-
541543
Object.keys(console).forEach(methodName => {
542544
const reactNativeMethod = console[methodName];
543545
if (originalConsole[methodName]) {

0 commit comments

Comments
 (0)