React,Material Ui:无法在隐藏菜单上映射值

问题描述

大家好,希望你们玩的开心

我映射了一个数组,一切都很好,但是所有隐藏的 menus(点击后打开)都显示了数组最后一项的 id,我无法找到它是否因为在映射时隐藏,但是我无法获取组件该部分中每个元素的 id

const [anchorEl,setAnchorEl] = React.useState(null);
    const handleClickPoints = (event) => {
        setAnchorEl(event.currentTarget);
      };
    const handleClose = () => {
        setAnchorEl(null);
    };
return (
{array.map((value)=>(  
    <Typography> {value.name} </Typography> 

     {/*
   some other values correctly mapped
*/}

{/*not mapping value.id here: */}
<MoreHorizIcon aria-controls="simple-menu" aria-haspopup="true" onClick={handleClickPoints} />
        <Menu
            id="simple-menu"
            anchorEl={anchorEl}
            keepMounted
            open={Boolean(anchorEl)}
            onClose={handleClose}
        >         
   <Link href={`/edit/${value.id}`}><MenuItem onClick={handleClose}><Typography>Edit details</Typography></MenuItem></Link>
        </Menu>
  ))}
)

知道如何映射隐藏菜单中的值吗?或者还能是什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)