@umijs/renderer-react 4.0.52 → 4.0.53
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.
- package/dist/appContext.d.ts +1 -0
- package/dist/appContext.js +13 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/types.d.ts +4 -1
- package/package.json +1 -1
package/dist/appContext.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ interface IAppContextType {
|
|
|
15
15
|
export declare const AppContext: React.Context<IAppContextType>;
|
|
16
16
|
export declare function useAppData(): IAppContextType;
|
|
17
17
|
export declare function useSelectedRoutes(): import("react-router-dom").RouteMatch<string>[];
|
|
18
|
+
export declare function useRouteProps<T extends Record<string, any> = any>(): T;
|
|
18
19
|
export declare function useServerLoaderData(): {
|
|
19
20
|
data: any;
|
|
20
21
|
};
|
package/dist/appContext.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
2
|
+
var _excluded = ["element"];
|
|
1
3
|
import React from 'react';
|
|
4
|
+
import { matchRoutes, useLocation } from 'react-router-dom';
|
|
2
5
|
import { useRouteData } from "./routeContext";
|
|
3
|
-
import { useLocation, matchRoutes } from 'react-router-dom';
|
|
4
6
|
export var AppContext = /*#__PURE__*/React.createContext({});
|
|
5
7
|
export function useAppData() {
|
|
6
8
|
return React.useContext(AppContext);
|
|
7
9
|
}
|
|
8
10
|
export function useSelectedRoutes() {
|
|
9
11
|
var location = useLocation();
|
|
10
|
-
|
|
11
12
|
var _useAppData = useAppData(),
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
14
|
+
// use `useLocation` get location without `basename`, not need `basename` param
|
|
15
15
|
var routes = matchRoutes(clientRoutes, location.pathname);
|
|
16
16
|
return routes || [];
|
|
17
17
|
}
|
|
18
|
+
export function useRouteProps() {
|
|
19
|
+
var _currentRoute$;
|
|
20
|
+
var currentRoute = useSelectedRoutes().slice(-1);
|
|
21
|
+
var _ref = ((_currentRoute$ = currentRoute[0]) === null || _currentRoute$ === void 0 ? void 0 : _currentRoute$.route) || {},
|
|
22
|
+
_ = _ref.element,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
return props;
|
|
25
|
+
}
|
|
18
26
|
export function useServerLoaderData() {
|
|
19
27
|
var route = useRouteData();
|
|
20
28
|
var appData = useAppData();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createBrowserHistory, createHashHistory, createMemoryHistory, type History, } from 'history';
|
|
2
|
-
export { createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
3
2
|
export { Helmet } from 'react-helmet-async';
|
|
4
|
-
export {
|
|
3
|
+
export { createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams, } from 'react-router-dom';
|
|
4
|
+
export { useAppData, useClientLoaderData, useRouteProps, useSelectedRoutes, useServerLoaderData, } from './appContext';
|
|
5
5
|
export { renderClient, __getRoot } from './browser';
|
|
6
6
|
export { LinkWithPrefetch as Link } from './link';
|
|
7
7
|
export { useRouteData } from './routeContext';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { createBrowserHistory, createHashHistory, createMemoryHistory } from 'history';
|
|
2
|
-
export { createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams } from 'react-router-dom';
|
|
3
2
|
export { Helmet } from 'react-helmet-async';
|
|
4
|
-
export {
|
|
3
|
+
export { createSearchParams, generatePath, matchPath, matchRoutes, Navigate, NavLink, Outlet, resolvePath, useLocation, useMatch, useNavigate, useOutlet, useOutletContext, useParams, useResolvedPath, useRoutes, useSearchParams } from 'react-router-dom';
|
|
4
|
+
export { useAppData, useClientLoaderData, useRouteProps, useSelectedRoutes, useServerLoaderData } from "./appContext";
|
|
5
5
|
export { renderClient, __getRoot } from "./browser";
|
|
6
6
|
export { LinkWithPrefetch as Link } from "./link";
|
|
7
7
|
export { useRouteData } from "./routeContext";
|
package/dist/types.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ export interface IRouteSSRProps {
|
|
|
3
3
|
clientLoader?: () => Promise<any>;
|
|
4
4
|
hasServerLoader?: boolean;
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface IRouteConventionExportProps {
|
|
7
|
+
routeProps?: Record<string, any>;
|
|
8
|
+
}
|
|
9
|
+
export interface IRoute extends IRouteSSRProps, IRouteConventionExportProps {
|
|
7
10
|
id: string;
|
|
8
11
|
path?: string;
|
|
9
12
|
index?: boolean;
|
package/package.json
CHANGED