Przeglądaj źródła

reload error

master
azri 4 tygodni temu
rodzic
commit
6678deb6e6
1 zmienionych plików z 7 dodań i 0 usunięć
  1. 7
    0
      src/App.js

+ 7
- 0
src/App.js Wyświetl plik

@@ -26,6 +26,13 @@ function App() {
26 26
 
27 27
   useEffect(() => {
28 28
 
29
+    // On Error
30
+    window.onerror = function (message, source, lineno, colno, error) {
31
+      console.error("Error occurred:", message, source, lineno, colno, error);
32
+      alert("An error occurred. The page will reload.");
33
+      window.location.reload();
34
+    };
35
+
29 36
     //Check if cart exist
30 37
     let cartHistory = localStorage.getItem('amber-cart');
31 38
     cartHistory = cartHistory ? JSON.parse(cartHistory) : {};

Ładowanie…
Anuluj
Zapisz