Skip to content

Commit 6e3ed01

Browse files
authored
Merge pull request #129 from Web-Dev-Path/fix/mobile-nav
Add `useEffect` to set navbar active status to false when route change
2 parents 58776f5 + 6cb863b commit 6e3ed01

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
5858
- improved LightHouse scores by optmizing images, creating a robots.txt file and adding proper alt tags
5959
- updated 'about us' first section (our background, peer reviews, version control)
6060
- updated 'about us' section (our goals, our purpose)
61+
- updated mobile nav to automatically close when page route change is completed

components/layout/Nav.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ export default function Nav() {
3939
};
4040
}, []);
4141

42+
useEffect(() => {
43+
const handleRouteChange = () => {
44+
setActive(false)
45+
}
46+
47+
router.events.on('routeChangeComplete', handleRouteChange)
48+
49+
return () => {
50+
router.events.off('routeChangeComplete', handleRouteChange)
51+
}
52+
}, []);
53+
54+
4255
return (
4356
<header className={styles.header} ref={headerRef}>
4457
<Container>

0 commit comments

Comments
 (0)