Skip to content

Commit

Permalink
Fix Appearance module when using Chrome Debugger
Browse files Browse the repository at this point in the history
Summary:
The appearance module uses sync native module methods which doesn't work with the chrome debugger. This broke in 0.62: #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
  • Loading branch information
TheSavior authored and alloy committed Apr 8, 2020
1 parent 6e530d9 commit 4fd9c9d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Libraries/Utilities/Appearance.js
Expand Up @@ -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();
Expand Down Expand Up @@ -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
Expand Down

1 comment on commit 4fd9c9d

@jyoo
Copy link

@jyoo jyoo commented on 4fd9c9d May 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Please sign in to comment.