I'm creating a table with Material UI inside a Webpack + ReactJS project
I want to add an 'icon menu' with one 'menu item' that would allow the user to delete the line and the linked datas. Here is the (revelant) code:
export default class GufreFile extends React.Component {
render(){
function alertTest() {
console.log('hello there');
}
return (
<TableRow>
//...
<TableRowColumn>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
>
<MenuItem primaryText="Delete" onTouchTap={ alertTest }/>
</IconMenu>
If I try with this code, everything works perfectly, I get 'hello there' if I click on my menu link.
However, if I do the following:
export default class GufreFile extends React.Component {
render(){
function alertTest(data) {
console.log(data);
}
return (
<TableRow>
//...
<TableRowColumn>
<IconMenu
iconButtonElement={<IconButton><MoreVertIcon /></IconButton>}
anchorOrigin={{horizontal: 'right', vertical: 'top'}}
targetOrigin={{horizontal: 'right', vertical: 'top'}}
>
<MenuItem primaryText="Delete" onTouchTap={ alertTest( this.props.data.id) }/>
it will make show my datas' id inside my console when I reload the page.
I don't know if this is a bug, or if I misunderstood anything.
Can someone help?
Thank you in advance