From c82d191dd8c4ca3e6258470317e1133fb735457c Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 30 Mar 2022 11:34:05 -0500 Subject: [PATCH] ThumbNavigationLink: fix runtime error No clue why that was happening --- app/soapbox/components/thumb_navigation-link.tsx | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/soapbox/components/thumb_navigation-link.tsx b/app/soapbox/components/thumb_navigation-link.tsx index ae3c4facb..756abd25c 100644 --- a/app/soapbox/components/thumb_navigation-link.tsx +++ b/app/soapbox/components/thumb_navigation-link.tsx @@ -15,14 +15,17 @@ interface IThumbNavigationLink { } const ThumbNavigationLink: React.FC = ({ count, src, text, to, exact, paths }): JSX.Element => { - const location = useLocation(); + const { pathname } = useLocation(); - const active = paths - ? paths.some(location.pathname.startsWith) - : (exact - ? location.pathname === to - : location.pathname.startsWith(to)); + const isActive = (): boolean => { + if (paths) { + return paths.some(path => pathname.startsWith(path)); + } else { + return exact ? pathname === to : pathname.startsWith(to); + } + }; + const active = isActive(); return (