Skip to content

Commit 0d81ff1

Browse files
committed
add useEffect to set navbar active status to false when route change complete
1 parent 58776f5 commit 0d81ff1

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

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 = (url, _) => {
44+
setActive(false)
45+
}
46+
47+
router.events.on('routeChangeStart', handleRouteChange)
48+
49+
return () => {
50+
router.events.off('routeChangeStart', handleRouteChange)
51+
}
52+
}, []);
53+
54+
4255
return (
4356
<header className={styles.header} ref={headerRef}>
4457
<Container>

0 commit comments

Comments
 (0)