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 ThumbNavigationLink: React.FC<IThumbNavigationLink> = ({ count, src, text, to, exact, paths }): JSX.Element => {
const location = useLocation(); const { pathname } = useLocation();
const active = paths const isActive = (): boolean => {
? paths.some(location.pathname.startsWith) if (paths) {
: (exact return paths.some(path => pathname.startsWith(path));
? location.pathname === to } else {
: location.pathname.startsWith(to)); return exact ? pathname === to : pathname.startsWith(to);
}
};
const active = isActive();
return ( return (
<NavLink to={to} exact={exact} className='thumb-navigation__link'> <NavLink to={to} exact={exact} className='thumb-navigation__link'>