File tree 1 file changed +9
-7
lines changed
packages/react-native/React/CoreModules
1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -39,10 +39,15 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
39
39
static UITraitCollection *getKeyWindowTraitCollection ()
40
40
{
41
41
__block UITraitCollection *traitCollection = nil ;
42
- RCTExecuteOnMainQueue (^{
43
- traitCollection = RCTSharedApplication ().delegate .window .traitCollection ;
44
- });
45
- return traitCollection;
42
+ if (RCTIsMainQueue ()) {
43
+ return RCTSharedApplication ().delegate .window .traitCollection ;
44
+ } else {
45
+ __block UITraitCollection* traitCollection = nil ;
46
+ dispatch_sync (dispatch_get_main_queue (), ^{
47
+ traitCollection = RCTSharedApplication ().delegate .window .traitCollection ;
48
+ });
49
+ return traitCollection;
50
+ }
46
51
}
47
52
48
53
NSString *RCTColorSchemePreference (UITraitCollection *traitCollection)
@@ -68,9 +73,6 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
68
73
69
74
traitCollection = traitCollection ?: getKeyWindowTraitCollection ();
70
75
return appearances[@(traitCollection.userInterfaceStyle)] ?: RCTAppearanceColorSchemeLight;
71
-
72
- // Default to light on older OS version - same behavior as Android.
73
- return RCTAppearanceColorSchemeLight;
74
76
}
75
77
76
78
@interface RCTAppearance () <NativeAppearanceSpec>
You can’t perform that action at this time.
0 commit comments