@umijs/renderer-react 4.0.56 → 4.0.57

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.
@@ -9,23 +9,18 @@ export function useAppData() {
9
9
  }
10
10
  export function useSelectedRoutes() {
11
11
  var location = useLocation();
12
-
13
12
  var _useAppData = useAppData(),
14
- clientRoutes = _useAppData.clientRoutes; // use `useLocation` get location without `basename`, not need `basename` param
15
-
16
-
13
+ clientRoutes = _useAppData.clientRoutes;
14
+ // use `useLocation` get location without `basename`, not need `basename` param
17
15
  var routes = matchRoutes(clientRoutes, location.pathname);
18
16
  return routes || [];
19
17
  }
20
18
  export function useRouteProps() {
21
19
  var _currentRoute$;
22
-
23
20
  var currentRoute = useSelectedRoutes().slice(-1);
24
-
25
21
  var _ref = ((_currentRoute$ = currentRoute[0]) === null || _currentRoute$ === void 0 ? void 0 : _currentRoute$.route) || {},
26
- _ = _ref.element,
27
- props = _objectWithoutProperties(_ref, _excluded);
28
-
22
+ _ = _ref.element,
23
+ props = _objectWithoutProperties(_ref, _excluded);
29
24
  return props;
30
25
  }
31
26
  export function useServerLoaderData() {
package/dist/link.js CHANGED
@@ -6,19 +6,16 @@ import { Link } from 'react-router-dom';
6
6
  import { useAppData } from "./appContext";
7
7
  export function LinkWithPrefetch(props) {
8
8
  var _props$to;
9
-
10
9
  var prefetch = props.prefetch,
11
- linkProps = _objectWithoutProperties(props, _excluded);
12
-
10
+ linkProps = _objectWithoutProperties(props, _excluded);
13
11
  var appData = useAppData();
14
- var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname; // compatible with old code
12
+ var to = typeof props.to === 'string' ? props.to : (_props$to = props.to) === null || _props$to === void 0 ? void 0 : _props$to.pathname;
13
+ // compatible with old code
15
14
  // which to might be undefined
16
-
17
15
  if (!to) return null;
18
16
  return /*#__PURE__*/React.createElement(Link, _extends({
19
17
  onMouseEnter: function onMouseEnter() {
20
18
  var _appData$preloadRoute;
21
-
22
19
  return prefetch && to && ((_appData$preloadRoute = appData.preloadRoute) === null || _appData$preloadRoute === void 0 ? void 0 : _appData$preloadRoute.call(appData, to));
23
20
  }
24
21
  }, linkProps), props.children);
package/dist/routes.js CHANGED
@@ -9,8 +9,8 @@ import { RouteContext, useRouteData } from "./routeContext";
9
9
  import { useAppData } from "./appContext";
10
10
  export function createClientRoutes(opts) {
11
11
  var routesById = opts.routesById,
12
- parentId = opts.parentId,
13
- routeComponents = opts.routeComponents;
12
+ parentId = opts.parentId,
13
+ routeComponents = opts.routeComponents;
14
14
  return Object.keys(routesById).filter(function (id) {
15
15
  return routesById[id].parentId === parentId;
16
16
  }).map(function (id) {
@@ -32,36 +32,28 @@ export function createClientRoutes(opts) {
32
32
  loadingComponent: opts.loadingComponent,
33
33
  reactRouter5Compat: opts.reactRouter5Compat
34
34
  });
35
-
36
35
  if (children.length > 0) {
37
- route.children = children; // TODO: remove me
36
+ route.children = children;
37
+ // TODO: remove me
38
38
  // compatible with @ant-design/pro-layout
39
-
40
39
  route.routes = children;
41
40
  }
42
-
43
41
  return route;
44
42
  });
45
43
  }
46
-
47
44
  function NavigateWithParams(props) {
48
45
  var params = useParams();
49
-
50
46
  var propsWithParams = _objectSpread(_objectSpread({}, props), {}, {
51
47
  to: generatePath(props.to, params)
52
48
  });
53
-
54
49
  return /*#__PURE__*/React.createElement(Navigate, _extends({
55
50
  replace: true
56
51
  }, propsWithParams));
57
52
  }
58
-
59
53
  function createClientRoute(opts) {
60
54
  var route = opts.route;
61
-
62
55
  var redirect = route.redirect,
63
- props = _objectWithoutProperties(route, _excluded);
64
-
56
+ props = _objectWithoutProperties(route, _excluded);
65
57
  var Remote = opts.reactRouter5Compat ? RemoteComponentReactRouter5 : RemoteComponent;
66
58
  return _objectSpread({
67
59
  element: redirect ? /*#__PURE__*/React.createElement(NavigateWithParams, {
@@ -77,27 +69,24 @@ function createClientRoute(opts) {
77
69
  }))
78
70
  }, props);
79
71
  }
80
-
81
72
  function DefaultLoading() {
82
73
  return /*#__PURE__*/React.createElement("div", null);
83
74
  }
84
-
85
75
  function RemoteComponentReactRouter5(props) {
86
76
  var _useRouteData = useRouteData(),
87
- route = _useRouteData.route;
88
-
77
+ route = _useRouteData.route;
89
78
  var _useAppData = useAppData(),
90
- history = _useAppData.history,
91
- clientRoutes = _useAppData.clientRoutes;
92
-
79
+ history = _useAppData.history,
80
+ clientRoutes = _useAppData.clientRoutes;
93
81
  var params = useParams();
94
82
  var match = {
95
83
  params: params,
96
84
  isExact: true,
97
85
  path: route.path,
98
86
  url: history.location.pathname
99
- }; // staticContext 没有兼容 好像没看到对应的兼容写法
87
+ };
100
88
 
89
+ // staticContext 没有兼容 好像没看到对应的兼容写法
101
90
  var Component = props.loader;
102
91
  return /*#__PURE__*/React.createElement(React.Suspense, {
103
92
  fallback: /*#__PURE__*/React.createElement(props.loadingComponent, null)
@@ -110,7 +99,6 @@ function RemoteComponentReactRouter5(props) {
110
99
  routes: clientRoutes
111
100
  }, props.hasChildren && /*#__PURE__*/React.createElement(Outlet, null)));
112
101
  }
113
-
114
102
  function RemoteComponent(props) {
115
103
  var Component = props.loader;
116
104
  return /*#__PURE__*/React.createElement(React.Suspense, {
@@ -2,8 +2,7 @@ import { useLocation } from 'react-router-dom';
2
2
  import { useAppData } from "./appContext";
3
3
  export function __useFetcher() {
4
4
  var _useAppData = useAppData(),
5
- preloadRoute = _useAppData.preloadRoute;
6
-
5
+ preloadRoute = _useAppData.preloadRoute;
7
6
  var location = useLocation();
8
7
  return {
9
8
  load: function load(path) {
@@ -37,6 +37,5 @@ export function withRouter(Component) {
37
37
  navigate: navigate
38
38
  }));
39
39
  }
40
-
41
40
  return ComponentWithRouterProp;
42
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "4.0.56",
3
+ "version": "4.0.57",
4
4
  "description": "@umijs/renderer-react",
5
5
  "homepage": "https://github.com/umijs/umi/tree/master/packages/renderer-react#readme",
6
6
  "bugs": "https://github.com/umijs/umi/issues",