Skip to content

Commit fa41b90

Browse files
Marcoo09okwasniewski
authored andcommitted
task(StatusBar component): show warn when using StatusBar (#49)
* task(StatusBar component): show warn when using StatusBar * pr suggestions
1 parent df6ff9d commit fa41b90

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
@@ -94,7 +94,9 @@ - (void)startObserving
9494

9595
- (void)stopObserving
9696
{
97+
#if !TARGET_OS_VISION
9798
[[NSNotificationCenter defaultCenter] removeObserver:self];
99+
#endif
98100
}
99101

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

0 commit comments

Comments
 (0)