ThumbNavigationLink: fix runtime error

No clue why that was happening
This commit is contained in:
Alex Gleason 2022-03-30 11:34:05 -05:00
parent 9fb3439cda
commit c82d191dd8
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 9 additions and 6 deletions

View File

@ -15,14 +15,17 @@ interface IThumbNavigationLink {
}
const ThumbNavigationLink: React.FC<IThumbNavigationLink> = ({ 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 (
<NavLink to={to} exact={exact} className='thumb-navigation__link'>