SidebarNavigationLink: fix isActive

This commit is contained in:
Alex Gleason 2024-10-26 17:11:24 -05:00
parent 47e5f4c9d1
commit 0a66f2585b
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import clsx from 'clsx'; import clsx from 'clsx';
import React from 'react'; import React from 'react';
import { NavLink } from 'react-router-dom'; import { NavLink, useLocation } from 'react-router-dom';
import { Icon, Text } from './ui'; import { Icon, Text } from './ui';
@ -24,7 +24,9 @@ interface ISidebarNavigationLink {
/** Desktop sidebar navigation link. */ /** Desktop sidebar navigation link. */
const SidebarNavigationLink = React.forwardRef((props: ISidebarNavigationLink, ref: React.ForwardedRef<HTMLAnchorElement>): JSX.Element => { const SidebarNavigationLink = React.forwardRef((props: ISidebarNavigationLink, ref: React.ForwardedRef<HTMLAnchorElement>): JSX.Element => {
const { icon, activeIcon, text, to = '', count, countMax, onClick } = props; const { icon, activeIcon, text, to = '', count, countMax, onClick } = props;
const isActive = location.pathname === to; const { pathname } = useLocation();
const isActive = pathname === to;
const handleClick: React.EventHandler<React.MouseEvent> = (e) => { const handleClick: React.EventHandler<React.MouseEvent> = (e) => {
if (onClick) { if (onClick) {