0

我正在使用 react native 弹出菜单https://github.com/instea/react-native-popup-menu如果用户从列表视图中单击另一个菜单,则未找到如何关闭已打开的菜单。

如果我使用带有 setState 的“打开”对象,例如 https://stackoverflow.com/a/42781164/3671295,它将打开我的所有弹出窗口,因为弹出菜单位于列表视图中。

在此之后,我尝试使用 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)}>

在上面的代码中,我尝试通过“ref”获取它来设置“opened”属性值,但无法成功。任何朋友都可以指导我如何在列表视图中使用弹出菜单,在新弹出窗口中打开已经打开的弹出窗口将关闭。

我也尝试了https://github.com/instea/react-native-popup-menu/blob/master/examples/MenuMethodsExample.js但它在列表视图中也不起作用。

4

0 回答 0