From 4b8d85859533efcd5089ad550a9429091133ee58 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Sun, 19 May 2024 02:53:12 -0700 Subject: [PATCH 1/2] feat: close mobile nav onclick --- src/app/components/Nav/Nav.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/components/Nav/Nav.js b/src/app/components/Nav/Nav.js index 3b142567..5b5212d3 100644 --- a/src/app/components/Nav/Nav.js +++ b/src/app/components/Nav/Nav.js @@ -10,9 +10,11 @@ import "./Nav.scss"; const Nav = () => { const { pathname } = useLocation(); const [mobileExpand, setMobileExpand] = useState(false); + const toggleMobileExpand = () => { setMobileExpand(!mobileExpand); }; + if (pathname === "/designathon22/" || pathname === "/designathon22") return <>; @@ -122,13 +124,19 @@ const Nav = () => { { label: "Contact", url: "/contact" }, { label: "Houses", url: "/houses" }, ].map(({ label, url }) => ( - + {label} ))} Join From 6ad835d9a6299914c68d34fc1bcbe80efc321f76 Mon Sep 17 00:00:00 2001 From: Kevin Wu Date: Mon, 20 May 2024 21:53:42 -0700 Subject: [PATCH 2/2] fix: wrap func in callback --- src/app/components/Nav/Nav.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/components/Nav/Nav.js b/src/app/components/Nav/Nav.js index 5b5212d3..fb579c75 100644 --- a/src/app/components/Nav/Nav.js +++ b/src/app/components/Nav/Nav.js @@ -1,4 +1,4 @@ -import { useState, memo } from "react"; +import { useState, memo, useCallback } from "react"; import { Link, useLocation } from "react-router-dom"; import { Text } from "app/components"; @@ -11,9 +11,9 @@ const Nav = () => { const { pathname } = useLocation(); const [mobileExpand, setMobileExpand] = useState(false); - const toggleMobileExpand = () => { + const toggleMobileExpand = useCallback(() => { setMobileExpand(!mobileExpand); - }; + }, [mobileExpand]); if (pathname === "/designathon22/" || pathname === "/designathon22") return <>;