I want to perform a print operation using react-to-print and I want to know which button (print or cancel) is clicked in the opened preview modal for this operation. How can I do that?
I tried using the beforeprint and afterprint methods, but they don't work for my purpose.
Unfortunately this is not supported by browsers at this time, so react-to-print
is not capable of providing this functionality.
From MDN:
The
afterprint
event is fired after the associated document has started printing or the print preview has been closed.
The whatwg spec defining the event also does not provide a mechanism for knowing
Related SO question: ONAFTERPRINT event fires on the wrong button