Skip to content

Commit

Permalink
feat: close mobile nav onclick (#123)
Browse files Browse the repository at this point in the history
* feat: close mobile nav onclick

* fix: wrap func in callback
  • Loading branch information
KevinWu098 authored Jun 5, 2024
1 parent 5a8b132 commit e0d557a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/app/components/Nav/Nav.js
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -10,9 +10,11 @@ import "./Nav.scss";
const Nav = () => {
const { pathname } = useLocation();
const [mobileExpand, setMobileExpand] = useState(false);
const toggleMobileExpand = () => {

const toggleMobileExpand = useCallback(() => {
setMobileExpand(!mobileExpand);
};
}, [mobileExpand]);

if (pathname === "/designathon22/" || pathname === "/designathon22")
return <></>;

Expand Down Expand Up @@ -122,13 +124,19 @@ const Nav = () => {
{ label: "Contact", url: "/contact" },
{ label: "Houses", url: "/houses" },
].map(({ label, url }) => (
<Link key={url} to={url} className="item center">
<Link
key={url}
to={url}
className="item center"
onClick={toggleMobileExpand}
>
<Text size="L">{label}</Text>
</Link>
))}
<Link
to="/join"
className="item center button fill sky"
onClick={toggleMobileExpand}
>
<Text size="L">Join</Text>
</Link>
Expand Down

0 comments on commit e0d557a

Please sign in to comment.