Skip to content

Commit

Permalink
Back out "fix: return the correct default trait collection"
Browse files Browse the repository at this point in the history
Summary:
Original commit changeset: f069fea8918f

Original Phabricator Diff: D49186069

bypass-github-export-checks

theory: getKeyWindowTraitCollection could get run in an async block, so there's a race to set the value. currently it gets read as nil on the first attempt

Reviewed By: sammy-SC

Differential Revision: D49449392

fbshipit-source-id: 3c71403fb30fa873a49bdc754c77797ed292a3f0
  • Loading branch information
philIip authored and facebook-github-bot committed Sep 20, 2023
1 parent 982f6f9 commit 7888338
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions packages/react-native/React/CoreModules/RCTAppearance.mm
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,6 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
return sColorSchemeOverride;
}

static UITraitCollection *getKeyWindowTraitCollection()
{
__block UITraitCollection *traitCollection = nil;
RCTExecuteOnMainQueue(^{
traitCollection = RCTSharedApplication().delegate.window.traitCollection;
});
return traitCollection;
}

NSString *RCTColorSchemePreference(UITraitCollection *traitCollection)
{
static NSDictionary *appearances;
Expand All @@ -66,7 +57,7 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
return RCTAppearanceColorSchemeLight;
}

traitCollection = traitCollection ?: getKeyWindowTraitCollection();
traitCollection = traitCollection ?: [UITraitCollection currentTraitCollection];
return appearances[@(traitCollection.userInterfaceStyle)] ?: RCTAppearanceColorSchemeLight;

// Default to light on older OS version - same behavior as Android.
Expand Down

0 comments on commit 7888338

Please sign in to comment.