@umijs/renderer-react 4.0.18 → 4.0.19
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/browser.js +2 -1
- package/dist/routes.js +18 -38
- package/package.json +1 -1
package/dist/appContext.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ interface IAppContextType {
|
|
|
10
10
|
clientLoaderData: ILoaderData;
|
|
11
11
|
preloadRoute?: (to: string) => void;
|
|
12
12
|
serverLoaderData: ILoaderData;
|
|
13
|
+
history?: any;
|
|
13
14
|
}
|
|
14
15
|
export declare const AppContext: React.Context<IAppContextType>;
|
|
15
16
|
export declare function useAppData(): IAppContextType;
|
package/dist/browser.js
CHANGED
|
@@ -203,7 +203,8 @@ export function renderClient(opts) {
|
|
|
203
203
|
basename: basename,
|
|
204
204
|
clientLoaderData: clientLoaderData,
|
|
205
205
|
serverLoaderData: serverLoaderData,
|
|
206
|
-
preloadRoute: handleRouteChange
|
|
206
|
+
preloadRoute: handleRouteChange,
|
|
207
|
+
history: opts.history
|
|
207
208
|
}
|
|
208
209
|
}, rootContainer);
|
|
209
210
|
};
|
package/dist/routes.js
CHANGED
|
@@ -3,9 +3,10 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
3
3
|
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
4
4
|
var _excluded = ["redirect"];
|
|
5
5
|
// @ts-ignore
|
|
6
|
-
import React
|
|
7
|
-
import { generatePath, Navigate, useParams,
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { generatePath, Navigate, useParams, Outlet } from 'react-router-dom';
|
|
8
8
|
import { RouteContext, useRouteData } from "./routeContext";
|
|
9
|
+
import { useAppData } from "./appContext";
|
|
9
10
|
export function createClientRoutes(opts) {
|
|
10
11
|
var routesById = opts.routesById,
|
|
11
12
|
parentId = opts.parentId,
|
|
@@ -82,52 +83,31 @@ function DefaultLoading() {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
function RemoteComponentReactRouter5(props) {
|
|
85
|
-
var location = useLocation();
|
|
86
|
-
var navigate = useNavigate();
|
|
87
|
-
var params = useParams();
|
|
88
|
-
|
|
89
86
|
var _useRouteData = useRouteData(),
|
|
90
87
|
route = _useRouteData.route;
|
|
91
88
|
|
|
92
|
-
var
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return navigate(-1);
|
|
104
|
-
},
|
|
105
|
-
goBack: function goBack() {
|
|
106
|
-
return navigate(-1);
|
|
107
|
-
},
|
|
108
|
-
location: location,
|
|
109
|
-
push: function push(url, state) {
|
|
110
|
-
return navigate(url, {
|
|
111
|
-
state: state
|
|
112
|
-
});
|
|
113
|
-
},
|
|
114
|
-
replace: function replace(url, state) {
|
|
115
|
-
return navigate(url, {
|
|
116
|
-
replace: true,
|
|
117
|
-
state: state
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}, [location, navigate]); // staticContext 没有兼容 好像没看到对应的兼容写法
|
|
89
|
+
var _useAppData = useAppData(),
|
|
90
|
+
history = _useAppData.history,
|
|
91
|
+
clientRoutes = _useAppData.clientRoutes;
|
|
92
|
+
|
|
93
|
+
var params = useParams();
|
|
94
|
+
var match = {
|
|
95
|
+
params: params,
|
|
96
|
+
isExact: true,
|
|
97
|
+
path: route.path,
|
|
98
|
+
url: history.location.pathname
|
|
99
|
+
}; // staticContext 没有兼容 好像没看到对应的兼容写法
|
|
122
100
|
|
|
123
101
|
var Component = props.loader;
|
|
124
102
|
return /*#__PURE__*/React.createElement(React.Suspense, {
|
|
125
103
|
fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
|
|
126
104
|
}, /*#__PURE__*/React.createElement(Component, {
|
|
127
|
-
location: location,
|
|
105
|
+
location: history.location,
|
|
128
106
|
match: match,
|
|
129
107
|
history: history,
|
|
130
|
-
params: params
|
|
108
|
+
params: params,
|
|
109
|
+
route: route,
|
|
110
|
+
routes: clientRoutes
|
|
131
111
|
}, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null)));
|
|
132
112
|
}
|
|
133
113
|
|
package/package.json
CHANGED