reactjs – In Electron JS app using React js, how do I listen to the save button event

I am using react js in my Electron js project. I want to be able to console a message saying “file is downloaded” when the user clicks on the save button the browse window. I am trying below solution to listen to the click event, but this triggers as soon as I click on the download button on my Electron app. How do I listen to the save event?

const ws = XLSX.utils.json_to_sheet(filteredDataArray);
    const wb = XLSX.utils.book_new();
    XLSX.utils.book_append_sheet(wb, ws, "Sheet1");
    const excelBuffer = XLSX.write(wb, { bookType: "xlsx", type: "array" });
    const blob = new Blob([excelBuffer], {
      type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    });

    const fileName =
      `sampleExcel.xlsx`;

    const href = URL.createObjectURL(blob);
    const link = document.createElement("a");
    link.href = href;
    link.download = fileName;

   

    // Add an event listener for the 'click' event
    link.addEventListener("click", () => {
      console.log(`File "${fileName}" is downloaded.`);
    });
    // ...
    document.body.appendChild(link);
    link.click();
    document.body.removeChild(link);
  };

Read more here: Source link