diff --git a/src/Components/Navbar/Navbar.jsx b/src/Components/Navbar/Navbar.jsx index 6d4ad86..935a50f 100644 --- a/src/Components/Navbar/Navbar.jsx +++ b/src/Components/Navbar/Navbar.jsx @@ -1,6 +1,6 @@ import React, { useEffect, useState, useRef } from "react"; import { scroller } from "react-scroll"; -import { useLocation, NavLink } from "react-router-dom"; +import { useLocation, NavLink, useNavigate } from "react-router-dom"; import { useSelector, useDispatch } from 'react-redux'; import { changeTheme } from "../../features/theme"; import logo from "../../assets/logo2.png"; @@ -11,6 +11,7 @@ import "./Navbar.css"; const Navbar = () => { const location = useLocation(); + const navigate = useNavigate(); const [sticky, setSticky] = useState(false); const [mobileMenu, setMobileMenu] = useState(false); const [visible, setVisible] = useState(true); @@ -59,8 +60,9 @@ const Navbar = () => { setMobileMenu(!mobileMenu); }; - const handleMenuItemClick = (sectionId, offset) => { - scrollToSection(sectionId, offset); + const handleMenuItemClick = (path, sectionId, offset) => { + navigate(path); + setTimeout(() => scrollToSection(sectionId, offset), 0); setMobileMenu(false); }; @@ -82,28 +84,28 @@ const Navbar = () => { : "" } ${visible ? "" : "hidden-nav"} ${theme}`} > - handleMenuItemClick("hero", 0)}> + handleMenuItemClick("/", "hero", 0)}>

Start Connect Hub

Logo