score:1

Accepted answer

ideally you should wrap mui icon components with <iconbutton> </iconbutton> you can import that using import {iconbutton} from '@material-ui/core' so in your case it will be <iconbutton onclick={deletepost}><deleteoutlineoutlinedicon /></iconbutton>

edit: to get the correct value for the name property try:

 let name = e.target.getattribute('name');

and by the way some attribute names aren't really appropriate to use in this condition and in some situations can maybe result in undesired behaviour (for example trying to set a name attribute on a <th> html element) you want a piece of data (a variable) which normally shouldn't even be done this way as you could just easily do deletepost(e,props.id) giving props.id as a parameter directly to your function.

score:0

a bit more context may be needed for people to fully comprehend the issue. on first look i am wondering why you are wrapping a component in a button.

to create an outlined button with an icon using material-ui i'd stick to the material-ui documentation. so something along the lines of:

    <button
    variant="outlined"
    color="secondary"
    classname={classes.button}
    starticon={<deleteicon />}
    >

where <deleteicon/> is an icon you need to import from the material-ui library.


Related Query

More Query from same tag