From fe8933e1081c4d0f856dd9db356ae7c92210461e Mon Sep 17 00:00:00 2001 From: VividTruthKeeper Date: Thu, 9 Feb 2023 15:52:04 +0500 Subject: [PATCH] nav links --- src/components/header/SubNav.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/header/SubNav.tsx b/src/components/header/SubNav.tsx index 5a04fcb..da33153 100644 --- a/src/components/header/SubNav.tsx +++ b/src/components/header/SubNav.tsx @@ -1,5 +1,5 @@ // Modules -import { Link } from "react-router-dom"; +import { Link, useLocation } from "react-router-dom"; import { v4 as uuidv4 } from "uuid"; import { motion } from "framer-motion"; import { useDispatch, useSelector } from "react-redux"; @@ -45,6 +45,13 @@ const SubNav = () => { api.get(data, setData); }, [language]); + const location = useLocation(); + useEffect(() => { + if (!location.pathname.includes("category")) return; + const category = location.pathname[location.pathname.length - 1]; + onClickLink(parseInt(category)); + }, [location]); + return (