From ded7c0e4bb72e3309716559a69f4f11e1e3c2302 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Thu, 4 May 2023 16:44:14 +0700
Subject: fixing loader

---
 src/pages/_app.jsx | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

(limited to 'src/pages/_app.jsx')

diff --git a/src/pages/_app.jsx b/src/pages/_app.jsx
index 2ab028bd..beacb122 100644
--- a/src/pages/_app.jsx
+++ b/src/pages/_app.jsx
@@ -17,12 +17,15 @@ function MyApp({ Component, pageProps }) {
   const [animateLoader, setAnimateLoader] = useState(false)
 
   useEffect(() => {
-    Router.events.on('routeChangeStart', () => setAnimateLoader(true))
-    Router.events.on('routeChangeComplete', () => setAnimateLoader(false))
+    const handleRouteChangeStart = () => setAnimateLoader(true)
+    const handleRouteChangeComplete = () => setAnimateLoader(false)
+
+    Router.events.on('routeChangeStart', handleRouteChangeStart)
+    Router.events.on('routeChangeComplete', handleRouteChangeComplete)
 
     return () => {
-      Router.events.off('routeChangeStart', () => setAnimateLoader(true))
-      Router.events.off('routeChangeComplete', () => setAnimateLoader(false))
+      Router.events.off('routeChangeStart', handleRouteChangeStart)
+      Router.events.off('routeChangeComplete', handleRouteChangeComplete)
     }
   }, [])
 
-- 
cgit v1.2.3

