From 1218d8109380488ab7d15538fe3f828883dbc822 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 10 Mar 2023 17:23:04 +0700
Subject: change mobile and desktop view

---
 src/core/components/views/MobileView.jsx | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'src/core/components/views/MobileView.jsx')

diff --git a/src/core/components/views/MobileView.jsx b/src/core/components/views/MobileView.jsx
index be8aa293..348572c6 100644
--- a/src/core/components/views/MobileView.jsx
+++ b/src/core/components/views/MobileView.jsx
@@ -1,11 +1,23 @@
-import isMobile from 'is-mobile'
 import { useEffect, useState } from 'react'
 
 const MobileView = ({ children }) => {
   const [view, setView] = useState(<></>)
 
   useEffect(() => {
-    if (isMobile()) setView(children)
+    const handleResize = () => {
+      if (window.innerWidth < 768) {
+        setView(children)
+      } else {
+        setView(<></>)
+      }
+    }
+
+    handleResize()
+    window.addEventListener('resize', handleResize)
+
+    return () => {
+      window.removeEventListener('resize', handleResize)
+    }
   }, [children])
 
   return view
-- 
cgit v1.2.3

