File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed
frontend/src/app/(home)/components/navbar Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
- import React from "react" ;
1
+ import React , { useEffect , useState } from "react" ;
2
2
import Link from "next/link" ;
3
3
import Header from "@/components/ui/Header" ;
4
4
5
5
const Navbar = ( ) => {
6
- const isActive = ( path : string ) => window . location . pathname === path ;
6
+ const [ currentPath , setCurrentPath ] = useState ( "" ) ;
7
+
8
+ useEffect ( ( ) => {
9
+ // Update the state with the current pathname on the client side
10
+ setCurrentPath ( window . location . pathname ) ;
11
+ } , [ ] ) ;
12
+
13
+ const isActive = ( path : string ) => currentPath === path ;
7
14
return (
8
15
< nav className = "flex justify-between items-center p-4 bg-gray-900" >
9
16
< div className = "flex-shrink-0" >
10
17
< Header />
11
18
</ div >
12
19
13
20
< div className = "flex space-x-6" >
14
- < Link href = "/home " className = { `text-primary-300 hover:underline ${ isActive ( "/" ) ? "opacity-100" : "opacity-50 hover:opacity-100" } ` } >
21
+ < Link href = "/" className = { `text-primary-300 hover:underline ${ isActive ( "/" ) ? "opacity-100" : "opacity-50 hover:opacity-100" } ` } >
15
22
Home
16
23
</ Link >
17
24
< Link href = "" className = { `text-primary-300 hover:underline ${ isActive ( "/about" ) ? "opacity-100" : "opacity-50 hover:opacity-100" } ` } >
You can’t perform that action at this time.
0 commit comments