How to access global data in material-ui MenuItem onClick function

32
May 23, 2019, at 07:10 AM

I have a list of items and each of them has a menu (material-ui Menu) with option (MenuItem) to edit and delete;

<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) always return sessionID of the last item in the array, How can I get this code to return sessionID of the clicked item ?

handleClick = event => {
    this.setState({ anchorEl: event.currentTarget });
  };
  handleClose = (e,action) => {
    this.setState({ anchorEl: null });
  };
READ ALSO
Javascript Switch-Case syntax is confusing me [duplicate]

Javascript Switch-Case syntax is confusing me [duplicate]

This question already has an answer here:

57
How do we make an elliptic terrain with matter.js?

How do we make an elliptic terrain with matter.js?

I am trying to use matterjs in order to make an elliptic terrain which can have many bodies in it

61
Errors Creating Simple Azure HDInsight Spark Cluster with Pulumi

Errors Creating Simple Azure HDInsight Spark Cluster with Pulumi

I am attempting to use the Pulumi Javascript SDK to create a HDInsight Spark Cluster on AzureI have followed the tutorials Pulumi provides on creating a "hello world" GCP Kubernetes cluster and gone through the JavaScript examples in the Pulumi Examples...

44