3

I am developing a SCORM course using React and I must detect when user closes the tab to send the correct event to Lms

I tried to search for similar questions, and even following the answers of this thread reactjs event listener beforeunload added but not removed I could not make it work, onbeforeunload is just not called.

Also componentwillunmount do not works when user closes the window directly.

Any suggestions about how I could achieve this?

felipeprov
  • 39
  • 1
  • 1
  • 3
  • 1
    componentWillUnmount will never work if the user closes the window. Though the beforeunload event should trigger. – Chris Jan 24 '18 at 08:50
  • ok, so i am in the good track, but struggling to make it work. i will try to update the question with a example. – felipeprov Jan 24 '18 at 17:08
  • Maybe similar https://stackoverflow.com/questions/39094138/reactjs-event-listener-beforeunload-added-but-not-removed – Mark Jan 26 '18 at 16:13
  • In fact, it was working but the way I was testing wasn't good. – felipeprov Jan 26 '18 at 17:25

0 Answers0