React-native-navigation: [v2][Android] registerComponentDidAppearListener doesn't work on sideMenu

Created on 21 Nov 2018  ·  9Comments  ·  Source: wix/react-native-navigation

Issue Description

Hey, guys.
Since RNN doesn't have toggleSideMenu implemented yet, we need to do some hack like below.
The problem I noticed is that Navigation.events().registerComponentDidAppearListener works perfectly on iOS for sideMenu, but it doesn't on Android.

Steps to Reproduce / Code Snippets / Screenshots

import { Navigation } from 'react-native-navigation';

const DRAWER_ID = 'Sidebar';

class Drawer {
  constructor() {
    this.visible = false;

    Navigation.events().registerComponentDidAppearListener(({ componentId }) => {
      if (componentId === DRAWER_ID) {
        this.visible = true;
      }
    });

    Navigation.events().registerComponentDidDisappearListener(({ componentId }) => {
      if (componentId === DRAWER_ID) {
        this.visible = false;
      }
    });
  }

  toggle() {
    try {
      const visibility = !this.visible;
      Navigation.mergeOptions(DRAWER_ID, {
        sideMenu: {
          left: {
            visible: visibility
          }
        }
      });
      this.visible = visibility;
    } catch (error) {
      console.warn(error);
    }
  }
}

export default new Drawer();

Environment

  • React Native Navigation version: 2.1.3
  • React Native version: 0.57.5
  • Platform(s) (iOS, Android, or both?): Android
  • Device info (Simulator/Device? OS version? Debug/Release?): Moto G5 Plus. Android 8.1.
Android acceptebug 📌 pinned

Most helpful comment

Hey,
Is there anything new on this?

All 9 comments

Hey,
Is there anything new on this?

Not sure if this is related, but I just noticed that every now and then, the side menu component I've specified has its "render" method called, but the actual side menu GUI doesn't update.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

Sorry, bot.
Up this one :)

The only way I achieved that a button close the sideMenu and that it could get invoked by a gesture after (without that hides automatically) is with that snippet:

  toggleOffSideMenu = () => {
    Navigation.mergeOptions(this.props.componentId, {
      sideMenu: {
        left: {
          enabled: false
        }
      }
    });
     Navigation.mergeOptions(this.props.componentId, {
       sideMenu: {
         left: {
           enabled: true
         }
       }
     });
  };

+1 => How can I get status of drawer visible/enable?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If you believe the issue is still relevant, please test on the latest Detox and report back. Thank you for your contributions.

The issue has been closed for inactivity.

Am still facing this issue of the sideMenu on android, how can i close/open the sidemenu using a button

Was this page helpful?
0 / 5 - 0 ratings