const router = useRouter(); useEffect(() => { if (isMenuOpen) { setMenuOpen(!isMenuOpen); } }, [router.asPath]);