score:1

Accepted answer

Make sure to pass playerId to onDelete method

1st way Since your onDelete function has a function inside function. Just call onDelete and pass playerId

       <Button onClick={onDelete(playerId)} color="primary" autoFocus>
          Yes
        </Button>

2st way Rewrite onDelete properly. There is no need to put fun inside a fun.

const onDelete = id => {
    try {
      Axios.delete('http://localhost:8000/service/player', id);
      setDeleteDialog(false);
    } catch (e) {
      console.log(e);
    }
  }

Now just call provide an inline arrow function to onClick

       <Button onClick={() => onDelete(playerId)} color="primary" autoFocus>
          Yes
        </Button>

score:0

<Dialog
    open={open}
    onClose={onClose}
    onDelete={onDelete}
    aria-labelledby="alert-dialog-title"
    aria-describedby="alert-dialog-description"
>

Dialog component doesn't have prop onDelete https://material-ui.com/api/dialog/


Related Query

More Query from same tag