Skip to content

Commit

Permalink
Use useMatch hook instead of matchPath
Browse files Browse the repository at this point in the history
We are not inside any loop so we can safely use `useMatch` hook.
  • Loading branch information
michalsmiarowski committed Jul 10, 2023
1 parent e288ce4 commit 1f37f71
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/components/SubNavigationPills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ const SubNavigationPills: FC<SubNavigationPillsProps> = ({ links }) => {
const NavPill: FC<NavPill> = ({ path, pathOverride, title, resolvedPaths }) => {
let isActive = false
const resolved = useResolvedPath(pathOverride || path)
const { pathname } = useLocation()
const match = matchPath(resolved.pathname, pathname)
const match = useMatch({ path: resolved.pathname, end: true })
if (match) {
if (match.params["*"]) {
const lastPieceOfPath = match.pathname.replace(match.pathnameBase, "")
Expand Down

0 comments on commit 1f37f71

Please sign in to comment.