From f7b90336be25b78935549aa140131d4d6d133f7b Mon Sep 17 00:00:00 2001 From: Eli White Date: Mon, 6 Apr 2020 18:15:08 -0700 Subject: [PATCH] Fix Appearance module when using Chrome Debugger Summary: The appearance module uses sync native module methods which doesn't work with the chrome debugger. This broke in 0.62: https://github.com/facebook/react-native/issues/26705 This fix makes the appearance module return 'light' when using the chrome debugger. Changelog: [Fixed] Appearance `getColorScheme` no longer breaks the debugger Reviewed By: yungsters Differential Revision: D20879779 fbshipit-source-id: ad49c66226096433bc9f270e004ad4a6f54fa8c2 --- Libraries/Utilities/Appearance.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Libraries/Utilities/Appearance.js b/Libraries/Utilities/Appearance.js index 39ea987a4afbc0..b63ff33c700c39 100644 --- a/Libraries/Utilities/Appearance.js +++ b/Libraries/Utilities/Appearance.js @@ -17,6 +17,7 @@ import NativeAppearance, { type ColorSchemeName, } from './NativeAppearance'; import invariant from 'invariant'; +import {isAsyncDebugging} from './DebugEnvironment'; type AppearanceListener = (preferences: AppearancePreferences) => void; const eventEmitter = new EventEmitter(); @@ -50,6 +51,14 @@ module.exports = { * @returns {?ColorSchemeName} Value for the color scheme preference. */ getColorScheme(): ?ColorSchemeName { + if (__DEV__) { + if (isAsyncDebugging) { + // Hard code light theme when using the async debugger as + // sync calls aren't supported + return 'light'; + } + } + // TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union const nativeColorScheme: ?string = NativeAppearance == null