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

Illegal callback invocation from native module. This callback type only permits a single invocation from native code. #64

Open
MAzeem6778 opened this issue Sep 9, 2024 · 0 comments

Comments

@MAzeem6778
Copy link

MAzeem6778 commented Sep 9, 2024

Description

The app crashed with the following error.

RuntimeException: Illegal callback invocation from native module. This callback type only permits a single invocation from native code.

logs in sentry:

com.facebook.react.bridge.CallbackImpl in invoke at line 26
com.facebook.react.bridge.PromiseImpl in reject at line 231
com.facebook.react.bridge.PromiseImpl in reject at line 70
com.reactnativesystemnavigationbar.SystemNavigationBarModule in fullScreen at line 118

react-native-system-navigation-bar version

2.6.4

React Native version

0.71.13

Snack, code example, screenshot, or link to a repository

// Handle full screem mode
  useEffect(() => {
    const handleOrientationChange = (orientation: OrientationType) => {
      switch (orientation) {
        case OrientationType['LANDSCAPE-LEFT']:
          toggleFullScreenMode(true);
          setTimeout(() => {
            Orientation.lockToLandscapeLeft();
            SystemNavigationBar.fullScreen(true);
          });
          break;

        case OrientationType['LANDSCAPE-RIGHT']:
          toggleFullScreenMode(true);
          setTimeout(() => {
            Orientation.lockToLandscapeRight();
            SystemNavigationBar.fullScreen(true);
          });
          break;

        default:
          toggleFullScreenMode(false);
          setTimeout(() => {
            Orientation.lockToPortrait();
            SystemNavigationBar.fullScreen(false);
          });
          break;
      }
      Orientation.unlockAllOrientations();
    };

    // Unlock all orientations at the start
    Orientation.unlockAllOrientations();

    // Add orientation listener
    Orientation.addDeviceOrientationListener(handleOrientationChange);

    // Cleanup on component unmount
    return () => {
      Orientation.removeDeviceOrientationListener(handleOrientationChange);
      Orientation.lockToPortrait(); // Ensure the app returns to portrait mode
    };
  }, []);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant