Reputation: 515
I am trying to add an onClick eventhandler into a material ui example and it is not being called.
<Tooltip title="Filter list">
<IconButton aria-label="Filter list">
<FilterListIcon/>
</IconButton onClick={test}>
</Tooltip>
test=()=>{
}
Heres the link to the code. sandbox editor https://codesandbox.io/s/kxq1oqxxjr
Thanks for the help.
Upvotes: 1
Views: 4821
Reputation: 112897
Make sure you add the event handler to the opening tag of IconButton
and it will work.
let EnhancedTableToolbar = props => {
const { numSelected, classes } = props;
const test = () => {
console.log("test");
};
return (
<Tooltip title="Filter list">
<IconButton aria-label="Filter list" onClick={test}>
<FilterListIcon />
</IconButton>
</Tooltip>
);
};
Upvotes: 4