diff --git a/components/Navbar/navDrop.js b/components/Navbar/navDrop.js index 443af86c..d1fc67a1 100644 --- a/components/Navbar/navDrop.js +++ b/components/Navbar/navDrop.js @@ -1,12 +1,24 @@ -import React,{useState,forwardRef} from 'react'; +import React,{useState,forwardRef, useEffect} from 'react'; import links from '../../config/links.json'; import Link from 'next/link'; import Dropdown from '../illustration/dropdown'; const NavDrop = forwardRef((props, ref)=> { - const {setDrop}=props; - const [show, setShow] = useState(null); + const {setDrop}=props; + const [show, setShow] = useState(null); + const [active, setActive] = useState(null); + const [activeSubMenu, setActiveSubMenu] = useState(null); + + const currentUrl = window.location.href + let currentMenu = currentUrl.split('/')[(currentUrl.split('/')).length - 2] + let currentSubMenu = "/" + currentMenu + '/' + currentUrl.split('/')[(currentUrl.split('/')).length - 1] + + useEffect(() => { + setActive(currentMenu) + setActiveSubMenu(currentSubMenu) + }, [currentUrl]) + return (