Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

task(StatusBar component): show warn when using StatusBar #49

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -417,6 +418,14 @@ class StatusBar extends React.Component<Props> {
* Updates the native status bar with the props from the stack.
*/
static _updatePropsStack = () => {
if (Platform.isVisionOS) {
warnOnce(
'StatusBar-unavailable',
'StatusBar is not available on visionOS platform.',
);
return;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to componentDidMount()

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


// Send the update to the native module only once at the end of the frame.
clearImmediate(StatusBar._updateImmediate);
StatusBar._updateImmediate = setImmediate(() => {
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