diff --git a/packages/react-native/React/CoreModules/RCTAlertController.mm b/packages/react-native/React/CoreModules/RCTAlertController.mm index 7999a937e697bd..16334d1bdf2fda 100644 --- a/packages/react-native/React/CoreModules/RCTAlertController.mm +++ b/packages/react-native/React/CoreModules/RCTAlertController.mm @@ -38,9 +38,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 0a0c21e1c2c521..ad2aa9f63afb00 100644 --- a/packages/react-native/React/CoreModules/RCTAppearance.mm +++ b/packages/react-native/React/CoreModules/RCTAppearance.mm @@ -96,7 +96,7 @@ - (instancetype)init { if ((self = [super init])) { #if !TARGET_OS_OSX // [macOS] - UITraitCollection *traitCollection = RCTSharedApplication().delegate.window.traitCollection; + UITraitCollection *traitCollection = RCTKeyWindow().traitCollection; _currentColorScheme = RCTColorSchemePreference(traitCollection); #else // [macOS NSAppearance *appearance = RCTSharedApplication().appearance;