我有一个项目列表,每个项目都有一个菜单(material-ui菜单),带有用于编辑和删除的选项(MenuItem);
<Menu
anchorEl={anchorEl}
open={Boolean(anchorEl)}
disableAutoFocusItem={true}
onClose = {handleClose}
elevation={1}>
<MenuItem onClick={(e)=>handleClose(e,editSession(session.id))}>
<EditOutlined color="primary" /> Edit session
</MenuItem>
<MenuItem onClick={(e)=>handleClose(e,deleteSession(session.id))}>
<DeleteOutline/> Delete session
</MenuItem>
</Menu>
editSession(session.id)始终返回数组中最后一项的sessionID,如何获取此代码以返回单击项的sessionID?
handleClick = event => {
this.setState({ anchorEl: event.currentTarget });
};
handleClose = (e,action) => {
this.setState({ anchorEl: null });
};