0

I am using react native pop up menu https://github.com/instea/react-native-popup-menu not found how to close already opened menu if user clicked on another from list view.

If I am using "opened" object with setState like https://stackoverflow.com/a/42781164/3671295 it will open my all pop up because pop up menu is in list view.

After this I tried to use react native "ref" like

    constructor(props, ctx) {
    super(props, ctx);
    this.myRef = React.createRef();
}
<Menu renderer={renderers.SlideInMenu} ref={(Menu) => { this.myRef = Menu; }} opened={false}>
    <MenuTrigger onPress={() => this.resetMenu(item.id)}>

In above code I tried to set "opened" attribute value by getting it by "ref" but can't get success . Can any buddy guide me how to use pop up menu in list view where opening on new pop up already opened pop up will close.

Also I tried https://github.com/instea/react-native-popup-menu/blob/master/examples/MenuMethodsExample.js but its also not working in list view.

priti narang
  • 258
  • 4
  • 18
  • not sure if I have understand well what do you want to do. but if you open one menu, the backdrop is rendered to catch clicks outside of menu and therefore you can't open another menu with single click. – sodik Dec 05 '18 at 08:09
  • actually I am using pop up menu in list view and its working fine but here when I am opening pop up on first list item it not closed automatically when I am opening other. I tried backdrop and other solution those are explained in question. – priti narang Dec 05 '18 at 08:56
  • I want an idea about how to close pop up menu by getting id of specific item. – priti narang Dec 05 '18 at 09:07
  • I don't understand `I am opening pop up on first list item it not closed automatically when I am opening other. ` - can you maybe rephrase it or describe it in more steps? And just to make it clear - you have one listview with multiple menu instances, right? – sodik Dec 05 '18 at 13:32

0 Answers0