diff --git a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js index 2ac3d1f6b09dad..13df2404be85b6 100644 --- a/packages/react-native/Libraries/Components/StatusBar/StatusBar.js +++ b/packages/react-native/Libraries/Components/StatusBar/StatusBar.js @@ -12,6 +12,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheet'; import processColor from '../../StyleSheet/processColor'; import Platform from '../../Utilities/Platform'; +import warnOnce from '../../Utilities/warnOnce'; import NativeStatusBarManagerAndroid from './NativeStatusBarManagerAndroid'; import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS'; import invariant from 'invariant'; @@ -393,6 +394,13 @@ class StatusBar extends React.Component { _stackEntry = null; componentDidMount() { + if (Platform.isVisionOS) { + warnOnce( + 'StatusBar-unavailable', + 'StatusBar is not available on visionOS platform.', + ); + return; + } // Every time a StatusBar component is mounted, we push it's prop to a stack // and always update the native status bar with the props from the top of then // stack. This allows having multiple StatusBar components and the one that is diff --git a/packages/react-native/React/CoreModules/RCTStatusBarManager.mm b/packages/react-native/React/CoreModules/RCTStatusBarManager.mm index d6433bea41e56c..ab5b1e94d03088 100644 --- a/packages/react-native/React/CoreModules/RCTStatusBarManager.mm +++ b/packages/react-native/React/CoreModules/RCTStatusBarManager.mm @@ -94,7 +94,9 @@ - (void)startObserving - (void)stopObserving { +#if !TARGET_OS_VISION [[NSNotificationCenter defaultCenter] removeObserver:self]; +#endif } - (void)emitEvent:(NSString *)eventName forNotification:(NSNotification *)notification