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/elements/Navbar/Search.jsx | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

(limited to 'src/core/components/elements/Navbar/Search.jsx')

diff --git a/src/core/components/elements/Navbar/Search.jsx b/src/core/components/elements/Navbar/Search.jsx
index e78f7f29..32a8d170 100644
--- a/src/core/components/elements/Navbar/Search.jsx
+++ b/src/core/components/elements/Navbar/Search.jsx
@@ -7,20 +7,14 @@ import { useRouter } from 'next/router'
 const Search = () => {
   const router = useRouter()
   const queryRef = useRef()
-  const [query, setQuery] = useState('')
+  const [query, setQuery] = useState(router.query.q || '')
   const [suggestions, setSuggestions] = useState([])
 
-  useEffect(() => {
-    setQuery(router.query.q)
-  }, [router.query])
-
   const loadSuggestion = useCallback(() => {
     if (query && document.activeElement == queryRef.current) {
-      ;(async () => {
-        const dataSuggestion = await searchSuggestApi({ query })
-        setSuggestions(dataSuggestion.data.suggestions)
-      })()
-      return
+      searchSuggestApi({ query }).then((response) => {
+        setSuggestions(response.data.suggestions)
+      })
     } else {
       setSuggestions([])
     }
-- 
cgit v1.2.3

