diff --git a/packages/react-native/React/CoreModules/RCTAlertController.mm b/packages/react-native/React/CoreModules/RCTAlertController.mm index 5c661e6fce12d4..b47ce0adefa06f 100644 --- a/packages/react-native/React/CoreModules/RCTAlertController.mm +++ b/packages/react-native/React/CoreModules/RCTAlertController.mm @@ -35,9 +35,8 @@ - (void)show:(BOOL)animated completion:(void (^)(void))completion { UIUserInterfaceStyle style = self.overrideUserInterfaceStyle; if (style == UIUserInterfaceStyleUnspecified) { - style = RCTSharedApplication().delegate.window.overrideUserInterfaceStyle - ? RCTSharedApplication().delegate.window.overrideUserInterfaceStyle - : UIUserInterfaceStyleUnspecified; + UIUserInterfaceStyle overriddenStyle = RCTKeyWindow().overrideUserInterfaceStyle; + style = overriddenStyle ? overriddenStyle : UIUserInterfaceStyleUnspecified; } self.overrideUserInterfaceStyle = style; diff --git a/packages/react-native/React/CoreModules/RCTAppearance.mm b/packages/react-native/React/CoreModules/RCTAppearance.mm index 543bc1b791bead..2ad68a589464e2 100644 --- a/packages/react-native/React/CoreModules/RCTAppearance.mm +++ b/packages/react-native/React/CoreModules/RCTAppearance.mm @@ -70,7 +70,7 @@ @implementation RCTAppearance { - (instancetype)init { if ((self = [super init])) { - UITraitCollection *traitCollection = RCTSharedApplication().delegate.window.traitCollection; + UITraitCollection *traitCollection = RCTKeyWindow().traitCollection; _currentColorScheme = RCTColorSchemePreference(traitCollection); [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appearanceChanged:)