diff --git a/src/components/global/Nav.tsx b/src/components/global/Nav.tsx index 055586d..60c55d1 100644 --- a/src/components/global/Nav.tsx +++ b/src/components/global/Nav.tsx @@ -1,5 +1,5 @@ // Modules -import { useRef, useEffect } from 'react'; +import { useRef, useEffect } from "react"; import { useLocation, Link } from "react-router-dom"; // Icons @@ -20,14 +20,17 @@ const Nav = ({ const refTrigger = useRef(null); useEffect(() => { - if(ref.current && refTrigger.current){ - window.addEventListener('click', (e:any) => { - if(!e.target.contains(ref.current) && !e.target.contains(refTrigger.current)){ + if (ref.current && refTrigger.current) { + window.addEventListener("click", (e: any) => { + if ( + !e.target.contains(ref.current) && + !e.target.contains(refTrigger.current) + ) { setDropdown(false); } - }) + }); } - }, [setDropdown, ref]) + }, [setDropdown, ref]); return (