|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { |
4 | | - Suspense, |
5 | | - useCallback, |
6 | | - useContext, |
7 | | - useEffect, |
8 | | - useRef, |
9 | | - useState, |
10 | | - useSyncExternalStore, |
11 | | -} from 'react' |
| 3 | +import { useCallback, useContext, useEffect, useRef, useState, useSyncExternalStore } from 'react' |
12 | 4 | import dynamic from 'next/dynamic' |
13 | 5 | import Image from 'next/image' |
14 | 6 | import Link from 'next/link' |
15 | | -import { useSearchParams } from 'next/navigation' |
16 | 7 | import { GithubOutlineIcon } from '@/components/icons' |
17 | 8 | import { cn } from '@/lib/core/utils/cn' |
18 | 9 | import { SessionContext } from '@/app/_shell/providers/session-provider' |
@@ -58,22 +49,16 @@ interface NavbarProps { |
58 | 49 | blogPosts?: NavBlogPost[] |
59 | 50 | } |
60 | 51 |
|
61 | | -export default function Navbar(props: NavbarProps) { |
62 | | - return ( |
63 | | - <Suspense fallback={null}> |
64 | | - <NavbarInner {...props} /> |
65 | | - </Suspense> |
66 | | - ) |
67 | | -} |
68 | | - |
69 | | -function NavbarInner({ logoOnly = false, blogPosts = [] }: NavbarProps) { |
| 52 | +export default function Navbar({ logoOnly = false, blogPosts = [] }: NavbarProps) { |
70 | 53 | const brand = getBrandConfig() |
71 | | - const searchParams = useSearchParams() |
72 | 54 | const sessionCtx = useContext(SessionContext) |
73 | 55 | const session = sessionCtx?.data ?? null |
74 | 56 | const isSessionPending = sessionCtx?.isPending ?? true |
75 | 57 | const isAuthenticated = Boolean(session?.user?.id) |
76 | | - const isBrowsingHome = searchParams.has('home') |
| 58 | + const [isBrowsingHome, setIsBrowsingHome] = useState(false) |
| 59 | + useEffect(() => { |
| 60 | + setIsBrowsingHome(new URLSearchParams(window.location.search).has('home')) |
| 61 | + }, []) |
77 | 62 | const useHomeLinks = isAuthenticated || isBrowsingHome |
78 | 63 | const logoHref = useHomeLinks ? '/?home' : '/' |
79 | 64 | const mounted = useSyncExternalStore( |
|
0 commit comments