Skip to content

Commit

Permalink
task(StatusBar component): show warn when using StatusBar (#49)
Browse files Browse the repository at this point in the history
* task(StatusBar component): show warn when using StatusBar

* pr suggestions
  • Loading branch information
Marcoo09 authored and okwasniewski committed Dec 12, 2023
1 parent 3dee764 commit 7959562
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -393,6 +394,13 @@ class StatusBar extends React.Component<Props> {
_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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ - (void)startObserving

- (void)stopObserving
{
#if !TARGET_OS_VISION
[[NSNotificationCenter defaultCenter] removeObserver:self];
#endif
}

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

0 comments on commit 7959562

Please sign in to comment.