Skip to content

Commit 10fbdb2

Browse files
authored
task(StatusBar component): show warn when using StatusBar (#49)
* task(StatusBar component): show warn when using StatusBar * pr suggestions
1 parent 9d9eb0f commit 10fbdb2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

packages/react-native/Libraries/Components/StatusBar/StatusBar.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {ColorValue} from '../../StyleSheet/StyleSheet';
1212

1313
import processColor from '../../StyleSheet/processColor';
1414
import Platform from '../../Utilities/Platform';
15+
import warnOnce from '../../Utilities/warnOnce';
1516
import NativeStatusBarManagerAndroid from './NativeStatusBarManagerAndroid';
1617
import NativeStatusBarManagerIOS from './NativeStatusBarManagerIOS';
1718
import invariant from 'invariant';
@@ -393,6 +394,13 @@ class StatusBar extends React.Component<Props> {
393394
_stackEntry = null;
394395

395396
componentDidMount() {
397+
if (Platform.isVisionOS) {
398+
warnOnce(
399+
'StatusBar-unavailable',
400+
'StatusBar is not available on visionOS platform.',
401+
);
402+
return;
403+
}
396404
// Every time a StatusBar component is mounted, we push it's prop to a stack
397405
// and always update the native status bar with the props from the top of then
398406
// stack. This allows having multiple StatusBar components and the one that is

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ - (void)startObserving
9191

9292
- (void)stopObserving
9393
{
94+
#if !TARGET_OS_VISION
9495
[[NSNotificationCenter defaultCenter] removeObserver:self];
96+
#endif
9597
}
9698

9799
- (void)emitEvent:(NSString *)eventName forNotification:(NSNotification *)notification

0 commit comments

Comments
 (0)