gitscope
← marzneshin / v0.5.6 / dashboard/src/hooks/use-is-current-route.ts
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/hooks/use-is-current-route.ts · TypeScript
Blame Raw
 1import { useRouterState } from "@tanstack/react-router";
 2
 3export const useIsCurrentRoute = () => {
 4    const router = useRouterState();
 5    const currentActivePath = router.location.pathname;
 6
 7    const isCurrentRouteActive = (path: string) => {
 8        if (path === "/") {
 9            return currentActivePath === path;
10        }
11        return currentActivePath.startsWith(path);
12    };
13
14    return { isCurrentRouteActive };
15}