Search code examples
reactjsinternet-explorerreloadpromptpage-refresh

ReactJS - Internet Explorer prompting stay/leave page on every refresh


Every time I reload the page in IE 11 or hotreload is triggered after saving changes in code, IE prompts me with pop up stay/leave on this site. Chrome and Firefox work fine.

This started to happen from one day to another day. I don't know what I have changed that caused this bug. Any clue what could be the problem ?

I have a ReactJS web application with redux and router.

Edit: FIX - looked for 'unload' in code and found

window.addEventListener('beforeunload', ev => {
  ev.preventDefault();

I deleted preventDefault() and now it works fine. At first i was looking exactly for 'onbeforeunload' so that's why I could find anything.


Solution

  • SOLUTION - FIX - At first, I was looking exactly for 'onbeforeunload' so that's why I could find anything. Then I looked for 'unload' in code and found

    window.addEventListener('beforeunload', ev => {
      ev.preventDefault();
    

    I deleted preventDefault() and now it works fine.