@umijs/renderer-react 4.0.84 → 4.0.86

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/server.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IRouteComponents, IRoutesById } from './types';
3
2
  export declare function getClientRootComponent(opts: {
4
3
  routes: IRoutesById;
@@ -9,4 +8,5 @@ export declare function getClientRootComponent(opts: {
9
8
  [routeKey: string]: any;
10
9
  };
11
10
  manifest: any;
11
+ withoutHTML?: boolean;
12
12
  }): Promise<JSX.Element>;
package/dist/server.js CHANGED
@@ -12,7 +12,7 @@ export function getClientRootComponent(_x) {
12
12
  }
13
13
  function _getClientRootComponent() {
14
14
  _getClientRootComponent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(opts) {
15
- var basename, components, clientRoutes, rootContainer, _i, _arr, key;
15
+ var basename, components, clientRoutes, rootContainer, _i, _arr, key, app;
16
16
  return _regeneratorRuntime().wrap(function _callee$(_context) {
17
17
  while (1) switch (_context.prev = _context.next) {
18
18
  case 0:
@@ -37,10 +37,7 @@ function _getClientRootComponent() {
37
37
  args: {}
38
38
  });
39
39
  }
40
- return _context.abrupt("return", /*#__PURE__*/React.createElement(Html, {
41
- loaderData: opts.loaderData,
42
- manifest: opts.manifest
43
- }, /*#__PURE__*/React.createElement(AppContext.Provider, {
40
+ app = /*#__PURE__*/React.createElement(AppContext.Provider, {
44
41
  value: {
45
42
  routes: opts.routes,
46
43
  routeComponents: opts.routeComponents,
@@ -50,8 +47,20 @@ function _getClientRootComponent() {
50
47
  clientLoaderData: {},
51
48
  serverLoaderData: opts.loaderData
52
49
  }
53
- }, rootContainer)));
54
- case 6:
50
+ }, rootContainer);
51
+ if (!opts.withoutHTML) {
52
+ _context.next = 8;
53
+ break;
54
+ }
55
+ return _context.abrupt("return", /*#__PURE__*/React.createElement("div", {
56
+ id: "root"
57
+ }, app));
58
+ case 8:
59
+ return _context.abrupt("return", /*#__PURE__*/React.createElement(Html, {
60
+ loaderData: opts.loaderData,
61
+ manifest: opts.manifest
62
+ }, app));
63
+ case 9:
55
64
  case "end":
56
65
  return _context.stop();
57
66
  }
@@ -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.84",
3
+ "version": "4.0.86",
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",