title: MATERIAL UI MENU ITEM performs action on page load
body: <p>I have an onClick event listener on a Menu Item in material UI, MUI.</p>
  <p>When I load the page, the onclick calls itself automatically. How can I fix this?</p>
  <pre><code>const [anchorEl, setAnchorEl] = useState(null)
    const open = Boolean(anchorEl)
    const handleClick = (event) =&gt; {
      setAnchorEl(event.currentTarget)
    }
    const handleClose = () =&gt; {
      setAnchorEl(null)
    }
  
  
    const handleDelete = async (postId, token) =&gt; {
      setLoading(true)
  
      const deleted = await deletePost(postId, token)
  
      if (deleted) {
        setLoading(false)
        toast.success(`Post deleted successfully`)
        history.push('/feed')
        handleClose()
      } else {
        toast.error('Something went wrong')
        setLoading(false)
        handleClose()
      }
    }
  
  
  &lt;IconButton
            id='demo-positioned-button'
            aria-controls={open ? 'demo-positioned-menu' : undefined}
            aria-haspopup='true'
            aria-expanded={open ? 'true' : undefined}
            onClick={handleClick}
          &gt;
            &lt;MoreVertIcon sx={{ color: '#E4E4E4' }} /&gt;
          &lt;/IconButton&gt;
  &lt;Menu 
  id='demo-positioned-menu'
            aria-labelledby='demo-positioned-button'
            anchorEl={anchorEl}
            open={open}
            onClose={handleClose}
            anchorOrigin={{
              vertical: 'top',
              horizontal: 'left',
            }}
            transformOrigin={{
              vertical: 'top',
              horizontal: 'left',
            }}
  &gt;
   &lt;MenuItem onClick={handleDelete(post._id, auth.token)}&gt;
     &lt;ListItemIcon&gt;
       &lt;DeleteIcon fontSize='small' /&gt;
     &lt;/ListItemIcon&gt;
     &lt;ListItemText&gt;Delete&lt;/ListItemText&gt;
   &lt;/MenuItem&gt;
  
   &lt;/Menu&gt;
  </code></pre>
  <p>When I load the page, the delete is called automatially and it repeats continuously, (Infinite loop) I have to reload the page.</p>
  <p>I tried with simple window.alert('Hello')</p>
  <p>It also alerts infinitely until i reload the page.</p>