@umijs/renderer-react 4.0.0-rc.12 → 4.0.0-rc.13

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.js CHANGED
@@ -40,6 +40,13 @@ export function renderClient(opts) {
40
40
  routeComponents: opts.routeComponents,
41
41
  loadingComponent: opts.loadingComponent,
42
42
  });
43
+ opts.pluginManager.applyPlugins({
44
+ key: 'patchClientRoutes',
45
+ type: 'event',
46
+ args: {
47
+ routes: clientRoutes,
48
+ },
49
+ });
43
50
  let rootContainer = (React.createElement(BrowserRoutes, { basename: basename, pluginManager: opts.pluginManager, routes: opts.routes, clientRoutes: clientRoutes, history: opts.history },
44
51
  React.createElement(Routes, null)));
45
52
  for (const key of [
package/dist/routes.js CHANGED
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
12
12
  // @ts-ignore
13
13
  import loadable from '@loadable/component';
14
14
  import React from 'react';
15
- import { Navigate } from 'react-router-dom';
15
+ import { Navigate, useLocation, useParams, useSearchParams, } from 'react-router-dom';
16
16
  import { RouteContext } from './routeContext';
17
17
  export function createClientRoutes(opts) {
18
18
  const { routesById, parentId, routeComponents } = opts;
@@ -47,14 +47,17 @@ export function createClientRoute(opts) {
47
47
  return Object.assign({ id: id, path: path, index: index, element: redirect ? (React.createElement(Navigate, { to: redirect })) : (React.createElement(RouteContext.Provider, { value: {
48
48
  route: opts.route,
49
49
  } },
50
- React.createElement(RemoteComponent, { loader: opts.routeComponent, loadingComponent: opts.loadingComponent || DefaultLoading }))) }, props);
50
+ React.createElement(RemoteComponent, { loader: opts.routeComponent, loadingComponent: opts.loadingComponent || DefaultLoading, route: route }))) }, props);
51
51
  }
52
52
  function DefaultLoading() {
53
53
  return React.createElement("div", null);
54
54
  }
55
55
  function RemoteComponent(props) {
56
+ const location = useLocation();
57
+ const params = useParams();
58
+ const [searchParams] = useSearchParams();
56
59
  const Component = loadable(props.loader, {
57
60
  fallback: React.createElement(props.loadingComponent, null),
58
61
  });
59
- return React.createElement(Component, null);
62
+ return (React.createElement(Component, { location: location, params: params, searchParams: searchParams, route: props.route }));
60
63
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umijs/renderer-react",
3
- "version": "4.0.0-rc.12",
3
+ "version": "4.0.0-rc.13",
4
4
  "description": "@umijs/renderer-react",
5
5
  "homepage": "https://github.com/umijs/umi-next/tree/master/packages/renderer-react#readme",
6
6
  "bugs": "https://github.com/umijs/umi-next/issues",
@@ -18,7 +18,8 @@
18
18
  "scripts": {
19
19
  "build": "pnpm tsc",
20
20
  "build:deps": "pnpm esno ../../scripts/bundleDeps.ts",
21
- "dev": "pnpm build -- --watch"
21
+ "dev": "pnpm build -- --watch",
22
+ "test": "jest -c ../../jest.turbo.config.ts"
22
23
  },
23
24
  "dependencies": {
24
25
  "@loadable/component": "5.15.2",