get pathname before checking if pathname changes
This commit is contained in:
@ -34,15 +34,15 @@ export const Header = () => {
|
||||
}
|
||||
}, [showMenu]);
|
||||
|
||||
const pathname = usePathname();
|
||||
// reset scroll position on path change
|
||||
useEffect(() => {
|
||||
if (!showMenu) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
}, [location.pathname, showMenu]);
|
||||
}, [pathname, showMenu]);
|
||||
|
||||
// hide menu and reset active menu item on path change
|
||||
const pathname = usePathname();
|
||||
useEffect(() => {
|
||||
setShowMenu(false);
|
||||
setActiveMenuItem(undefined);
|
||||
|
Reference in New Issue
Block a user