React | How to detect Page Refresh (F5)

Place this in the constructor:

if (window.performance) {
  if (performance.navigation.type == 1) {
    alert( "This page is reloaded" );
  } else {
    alert( "This page is not reloaded");
  }
}

It will work, please see this example on stackblitz.

references:

https://stackoverflow.com/questions/50026028/react-how-to-detect-page-refresh-f5