react-new-window icon indicating copy to clipboard operation
react-new-window copied to clipboard

is there a way to know if the window is closed?

Open ashwinkhode opened this issue 4 years ago • 2 comments

Hi, I want to know if we can pass onClose handler or some alternative so that we can know if the new window is closed or not.

Use case: I want to show a loader in a button and want to stop the loader if an user manually closes the popup

ashwinkhode avatar Jan 08 '22 12:01 ashwinkhode

Hi, I want to know if we can pass onClose handler or some alternative so that we can know if the new window is closed or not.

Use case: I want to show a loader in a button and want to stop the loader if an user manually closes the popup

you'll use onOpen and watch event;

onOpen={e => {
  const popupTick = setInterval(() => {
    if (e.closed) {
      clearInterval(popupTick);
      showLoading(false);
    }
  }, 500);
}}

ilhantekir avatar Jan 11 '22 07:01 ilhantekir

Thank you so much @ilhantekir! I will try this out

ashwinkhode avatar Jan 11 '22 11:01 ashwinkhode