Skip to content

Commit ee84f65

Browse files
committed
key in Handle can be anything, not necessary a string
1 parent a89efbe commit ee84f65

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

src/examples/basic/types.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Params } from "react-router-dom";
22

33
export type TabHandle = {
4-
key: string;
4+
key: any;
55
title: (props: { params: Params }) => string;
66
};
77

src/examples/basic/utils.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { DataRouteMatch, RouteObject, UIMatch } from "react-router-dom";
1+
import { RouteObject, UIMatch } from "react-router-dom";
22
import { Handle, TabHandle } from "./types";
33
import { flattenRoutes } from "src/lib/tabs";
44
import { InsertMethod, TabConfig } from "src/lib/tabs/useRouterTabs.tsx";
55

6-
export const convertRouteTreeToConfig = (tree: RouteObject[], key: string) => {
6+
export const convertRouteTreeToConfig = (tree: RouteObject[], key: any) => {
77
const flatRoutes = flattenRoutes(tree);
88

99
const matchedRoutes = flatRoutes.filter((route) => {
@@ -23,14 +23,6 @@ export const convertRouteTreeToConfig = (tree: RouteObject[], key: string) => {
2323
return config;
2424
};
2525

26-
export const getTabHandle =
27-
(key: string) =>
28-
(match: DataRouteMatch): TabHandle | undefined => {
29-
return (match.route?.handle as Handle | undefined)?.tabs.find(
30-
(tabHandle: TabHandle) => tabHandle.key === key,
31-
);
32-
};
33-
3426
export const getTabHandleUI =
3527
(key: string) =>
3628
(match: UIMatch<any, Handle>): TabHandle | undefined => {

0 commit comments

Comments
 (0)