@umijs/renderer-react 4.3.18 → 4.3.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/browser.d.ts CHANGED
@@ -88,4 +88,4 @@ export declare type RenderClientOpts = {
88
88
  * @param {RenderClientOpts} opts - 插件相关的配置
89
89
  * @returns void
90
90
  */
91
- export declare function renderClient(opts: RenderClientOpts): (() => React.JSX.Element) | undefined;
91
+ export declare function renderClient(opts: RenderClientOpts): (() => JSX.Element) | undefined;
package/dist/html.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import React from 'react';
2
2
  import { IHtmlProps } from './types';
3
- export declare function Html({ children, loaderData, manifest, htmlPageOpts, __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, mountElementId, }: React.PropsWithChildren<IHtmlProps>): React.JSX.Element;
3
+ export declare function Html({ children, loaderData, manifest, htmlPageOpts, __INTERNAL_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, mountElementId, }: React.PropsWithChildren<IHtmlProps>): JSX.Element;
package/dist/link.d.ts CHANGED
@@ -2,4 +2,4 @@ import React, { PropsWithChildren } from 'react';
2
2
  import { LinkProps } from 'react-router-dom';
3
3
  export declare function LinkWithPrefetch(props: PropsWithChildren<{
4
4
  prefetch?: boolean;
5
- } & LinkProps & React.RefAttributes<HTMLAnchorElement>>): React.JSX.Element | null;
5
+ } & LinkProps & React.RefAttributes<HTMLAnchorElement>>): JSX.Element | null;
package/dist/server.js CHANGED
@@ -17,7 +17,7 @@ function _getClientRootComponent() {
17
17
  return _regeneratorRuntime().wrap(function _callee$(_context) {
18
18
  while (1) switch (_context.prev = _context.next) {
19
19
  case 0:
20
- basename = '/';
20
+ basename = opts.basename || '/';
21
21
  components = _objectSpread({}, opts.routeComponents); // todo 参数对齐
22
22
  clientRoutes = createClientRoutes({
23
23
  routesById: opts.routes,
@@ -30,7 +30,13 @@ function _getClientRootComponent() {
30
30
  routes: clientRoutes
31
31
  }
32
32
  });
33
- rootContainer = /*#__PURE__*/React.createElement(StaticRouter, {
33
+ rootContainer =
34
+ /*#__PURE__*/
35
+ // 这里的 location 需要包含 basename, 否则会影响 StaticRouter 的匹配.
36
+ // 由于 getClientRootComponent 方法会同时用于 ssr 和 ssg, 所以在调用该方法时需要注意传入的 location 是否包含 basename.
37
+ // 1. 在用于 ssr 时传入的 location 来源于 request.url, 它是包含 basename 的, 所以没有问题.
38
+ // 2. 但是在用于 ssg 时(static export), 需要注意传入的 locaiton 要拼接上 basename.
39
+ React.createElement(StaticRouter, {
34
40
  basename: basename,
35
41
  location: opts.location
36
42
  }, /*#__PURE__*/React.createElement(Routes, null));
package/dist/types.d.ts CHANGED
@@ -64,6 +64,7 @@ export interface IRootComponentOptions extends IHtmlHydrateOptions {
64
64
  [routeKey: string]: any;
65
65
  };
66
66
  manifest: any;
67
+ basename?: string;
67
68
  }
68
69
  export interface IHtmlProps extends IHtmlHydrateOptions {
69
70
  children?: React.ReactNode;
@@ -14,4 +14,4 @@ export interface RouteComponentProps<T = ReturnType<typeof useParams>> {
14
14
  params?: T;
15
15
  navigate?: ReturnType<typeof useNavigate>;
16
16
  }
17
- export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => React.JSX.Element;
17
+ export declare function withRouter<P extends RouteComponentProps<P>>(Component: React.ComponentType<P>): (props: P) => JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "4.3.18",
3
+ "version": "4.3.19",
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",