Skip to content

Commit

Permalink
fix: close mobile nav after navigating to a new page
Browse files Browse the repository at this point in the history
jerelmiller committed Aug 9, 2020
1 parent 5c46e39 commit 641f057
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/layouts/MainLayout.js
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ import Sidebar from '../components/Sidebar';
import CookieApprovalDialog from '../components/CookieApprovalDialog';
import '../components/styles.scss';
import usePageContext from '../hooks/usePageContext';
import { useLocation } from '@reach/router';

const gaTrackingId = 'UA-3047412-33';
const gdprConsentCookieName = 'newrelic-gdpr-consent';
@@ -33,6 +34,7 @@ const MainLayout = ({ children }) => {
}
`);

const location = useLocation();
const { fileRelativePath } = usePageContext();
const [cookieConsent, setCookieConsent] = useState(false);
const [isMobileNavOpen, setIsMobileNavOpen] = useState(false);
@@ -48,6 +50,10 @@ const MainLayout = ({ children }) => {
consentValue && setCookieConsent(true);
}, []);

useEffect(() => {
setIsMobileNavOpen(false);
}, [location.pathname]);

return (
<div
css={css`

0 comments on commit 641f057

Please sign in to comment.