dumi 2.4.6 → 2.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
Binary file
|
|
@@ -12,7 +12,7 @@ export { useLiveDemo } from './useLiveDemo';
|
|
|
12
12
|
export { useLocale } from './useLocale';
|
|
13
13
|
export { useNavData } from './useNavData';
|
|
14
14
|
export { usePrefersColor } from './usePrefersColor';
|
|
15
|
-
export { useRouteMeta } from './useRouteMeta';
|
|
15
|
+
export { useMatchedRoute, useRouteMeta } from './useRouteMeta';
|
|
16
16
|
export { useFullSidebarData, useSidebarData } from './useSidebarData';
|
|
17
17
|
export { useSiteSearch } from './useSiteSearch';
|
|
18
18
|
export { useTabMeta } from './useTabMeta';
|
|
@@ -11,7 +11,7 @@ export { useLiveDemo } from "./useLiveDemo";
|
|
|
11
11
|
export { useLocale } from "./useLocale";
|
|
12
12
|
export { useNavData } from "./useNavData";
|
|
13
13
|
export { usePrefersColor } from "./usePrefersColor";
|
|
14
|
-
export { useRouteMeta } from "./useRouteMeta";
|
|
14
|
+
export { useMatchedRoute, useRouteMeta } from "./useRouteMeta";
|
|
15
15
|
export { useFullSidebarData, useSidebarData } from "./useSidebarData";
|
|
16
16
|
export { useSiteSearch } from "./useSiteSearch";
|
|
17
17
|
export { useTabMeta } from "./useTabMeta";
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { IRouteMeta } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* hook for get matched route
|
|
4
|
+
* @internal internal use. Do not use in your production code.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useMatchedRoute: () => {
|
|
7
|
+
[key: string]: any;
|
|
8
|
+
path?: string | undefined;
|
|
9
|
+
parentId?: string | undefined;
|
|
10
|
+
meta?: IRouteMeta | undefined;
|
|
11
|
+
id: string;
|
|
12
|
+
redirect?: string | undefined;
|
|
13
|
+
};
|
|
2
14
|
/**
|
|
3
15
|
* hook for get matched route meta
|
|
4
16
|
*/
|
|
@@ -73,9 +73,10 @@ function getCachedRouteMeta(route) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
/**
|
|
76
|
-
* hook for get matched route
|
|
76
|
+
* hook for get matched route
|
|
77
|
+
* @internal internal use. Do not use in your production code.
|
|
77
78
|
*/
|
|
78
|
-
export var
|
|
79
|
+
export var useMatchedRoute = function useMatchedRoute() {
|
|
79
80
|
var _useRouteData = useRouteData(),
|
|
80
81
|
route = _useRouteData.route;
|
|
81
82
|
var _useLocation = useLocation(),
|
|
@@ -99,9 +100,16 @@ export var useRouteMeta = function useRouteMeta() {
|
|
|
99
100
|
_useState2 = _slicedToArray(_useState, 2),
|
|
100
101
|
matchedRoute = _useState2[0],
|
|
101
102
|
setMatchedRoute = _useState2[1];
|
|
102
|
-
var meta = getCachedRouteMeta(matchedRoute);
|
|
103
103
|
useIsomorphicLayoutEffect(function () {
|
|
104
104
|
setMatchedRoute(getter);
|
|
105
105
|
}, [clientRoutes.length, pathname]);
|
|
106
|
-
return
|
|
106
|
+
return matchedRoute;
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* hook for get matched route meta
|
|
111
|
+
*/
|
|
112
|
+
export var useRouteMeta = function useRouteMeta() {
|
|
113
|
+
var route = useMatchedRoute();
|
|
114
|
+
return getCachedRouteMeta(route);
|
|
107
115
|
};
|