Skip to content

Commit a4564b1

Browse files
committed
use RCTUnsafeExecuteOnMainQueueSync
1 parent 5715b14 commit a4564b1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

packages/react-native/React/CoreModules/RCTAppearance.mm

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,10 @@ void RCTOverrideAppearancePreference(NSString *const colorSchemeOverride)
3939
static UITraitCollection *getKeyWindowTraitCollection()
4040
{
4141
__block UITraitCollection *traitCollection = nil;
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-
}
42+
RCTUnsafeExecuteOnMainQueueSync(^{
43+
traitCollection = RCTSharedApplication().delegate.window.traitCollection;
44+
});
45+
return traitCollection;
5146
}
5247

5348
NSString *RCTColorSchemePreference(UITraitCollection *traitCollection)

0 commit comments

Comments
 (0)