Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: close mobile nav onclick #123

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/app/components/Nav/Nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import "./Nav.scss";
const Nav = () => {
const { pathname } = useLocation();
const [mobileExpand, setMobileExpand] = useState(false);

const toggleMobileExpand = () => {
setMobileExpand(!mobileExpand);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know you didn't write this but can you wrap in usecallback and then use the functional set state

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀 i wrapped it in a callback, but i got no clue what "functional set state" is referring to 😅


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