Skip to content

Commit

Permalink
try again
Browse files Browse the repository at this point in the history
  • Loading branch information
drippypop committed Oct 4, 2024
1 parent 6b8d6f9 commit 7725202
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions Website/app/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@ import Image from "next/image";
import { useState } from "react";
import Link from "next/link";
import { useCallback, useEffect } from "react";
import { useRouter } from 'next/router';

function handleNavLinkClick(to, setOpen, router) {
if (window.location.pathname === to) {
setOpen(false);
} else {
router.push(to);
}
}
import { useRouter } from 'next/navigation';

function NavLink({ to, children, cn, setOpen }) {
const router = useRouter();
const handleNavLinkClick = (e) => {
e.preventDefault();
if (router.pathname === to) {
setOpen(false);
} else {
router.push(to);
}
};

return (
<button
onClick={() => handleNavLinkClick(to, setOpen)}
className={`text-gray-900 hover:text-black ${cn}`}
>
<Link href={to} className={`text-gray-900 hover:text-black ${cn}`} onClick={handleNavLinkClick}>
{children}
</button>
</Link>
);
}

Expand Down

0 comments on commit 7725202

Please sign in to comment.