This commit is contained in:
Proddy
2023-12-02 11:05:17 +01:00
parent c38832ef06
commit 06bf2f3427
12 changed files with 246 additions and 202 deletions

View File

@@ -1,8 +1,12 @@
import { useLocation } from 'react-router-dom';
import { useMatch, useResolvedPath } from 'react-router-dom';
export const useRouterTab = () => {
const loc = useLocation().pathname;
const routerTab = loc.substring(0, loc.lastIndexOf('/')) ? loc : false;
// const loc = useLocation().pathname;
// const routerTab = loc.substring(0, loc.lastIndexOf('/')) ? loc : false;
const routerTabPath = useResolvedPath(':tab');
const routerTabPathMatch = useMatch(routerTabPath.pathname);
const routerTab = routerTabPathMatch?.params?.tab || false;
return { routerTab } as const;
};