@modern-js/main-doc 0.0.0-next-1686722870675 → 0.0.0-next-1686752256456
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/CHANGELOG.md +3 -2
- package/docs/en/apis/app/runtime/core/bootstrap.mdx +5 -5
- package/docs/en/apis/app/runtime/core/use-loader.mdx +2 -2
- package/docs/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +1 -1
- package/docs/en/apis/app/runtime/testing/render.mdx +1 -1
- package/docs/en/guides/advanced-features/code-split.mdx +1 -1
- package/docs/en/guides/advanced-features/ssr.mdx +2 -2
- package/docs/zh/apis/app/runtime/testing/render.mdx +1 -1
- package/docs/zh/guides/advanced-features/code-split.mdx +1 -1
- package/docs/zh/guides/advanced-features/ssr.mdx +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @modern-js/main-doc
|
|
2
2
|
|
|
3
|
-
## 0.0.0-next-
|
|
3
|
+
## 0.0.0-next-1686752256456
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
- 8bb0e146f: chore: review code split docs
|
|
36
36
|
chore: 审查代码分割文档
|
|
37
37
|
- Updated dependencies [7e6fb5fc1]
|
|
38
|
-
|
|
38
|
+
- Updated dependencies [692cc0ed2]
|
|
39
|
+
- @modern-js/builder-doc@0.0.0-next-1686752256456
|
|
39
40
|
|
|
40
41
|
## 2.22.1
|
|
41
42
|
|
|
@@ -3,7 +3,7 @@ title: bootstrap
|
|
|
3
3
|
---
|
|
4
4
|
# bootstrap
|
|
5
5
|
|
|
6
|
-
Used to start and mount App, usually
|
|
6
|
+
Used to start and mount App, usually not manually called. This API is only required when using [Custom Bootstrap](/guides/concept/entries#custom-bootstrap).
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
@@ -32,10 +32,10 @@ type BootStrap<T = unknown> = (
|
|
|
32
32
|
|
|
33
33
|
### Input
|
|
34
34
|
|
|
35
|
-
- `AppComponent`:
|
|
36
|
-
- `rootId`: DOM root element id to mount,
|
|
37
|
-
- `root`:
|
|
38
|
-
- `ReactDOM`: ReactDOM object
|
|
35
|
+
- `AppComponent`: The ReactElement instance created by [`createApp`](./create-app).
|
|
36
|
+
- `rootId`: DOM root element id to mount, such as `"root"`.
|
|
37
|
+
- `root`: The return value of ReactDOM.createRoot, used for scenarios where the root needs to be destroyed outside of the bootstrap function.
|
|
38
|
+
- `ReactDOM`: The ReactDOM object, used to differentiate between React 18 and React 17 APIs.
|
|
39
39
|
|
|
40
40
|
## Example
|
|
41
41
|
|
|
@@ -3,10 +3,10 @@ title: useLoader
|
|
|
3
3
|
---
|
|
4
4
|
# useLoader
|
|
5
5
|
|
|
6
|
-
Isomorphic API, usually used to make asynchronous requests.
|
|
6
|
+
`useLoader` is an Isomorphic API, usually used to make asynchronous requests. During Server-Side Rendering (SSR), the server uses `useLoader` to prefetch the data, which is then reused on the client side.
|
|
7
7
|
|
|
8
8
|
:::tip
|
|
9
|
-
|
|
9
|
+
The `useLoader` API is currently not supported when using Rspack as the bundler.
|
|
10
10
|
:::
|
|
11
11
|
|
|
12
12
|
## Usage
|
|
@@ -3,7 +3,7 @@ title: useModuleApps
|
|
|
3
3
|
---
|
|
4
4
|
# useModuleApps
|
|
5
5
|
|
|
6
|
-
Returns the React components of all micro-front-end sub-applications for
|
|
6
|
+
Returns the React components of all micro-front-end sub-applications, allowing for flexible control over routing.
|
|
7
7
|
|
|
8
8
|
## Usage
|
|
9
9
|
|
|
@@ -107,7 +107,7 @@ After starting the application in this way, accessing the `/dashboard` route wil
|
|
|
107
107
|
|
|
108
108
|
## Load Animation
|
|
109
109
|
|
|
110
|
-
|
|
110
|
+
You can customize the transition animation of the component loading process as follows.
|
|
111
111
|
|
|
112
112
|
```tsx title=App.tsx
|
|
113
113
|
function App() {
|
|
@@ -41,7 +41,7 @@ function render(ui: React.ReactElement<any>, options: Options): RenderResult;
|
|
|
41
41
|
- `options`: render options.
|
|
42
42
|
- `container`: the dom which component mounted. by default create a `div` element, and auto append to `document.body`. the default value is `document.body.append(document.createElement('div'))`.
|
|
43
43
|
- `baseElement`: Used to specify the `basename` used in `queries`. If `container` is specified, the default value is the value of `container`, otherwise it is `document.body`.
|
|
44
|
-
- `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://
|
|
44
|
+
- `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://react.dev/reference/react-dom/hydrate) rendering component is used. The default value is `false`.
|
|
45
45
|
- `wrapper`: a react component that can be used to customize rendering logic.
|
|
46
46
|
- `queries`: customize some own `queries`.
|
|
47
47
|
|
|
@@ -75,7 +75,7 @@ Warning: Expected server HTML to contain a matching <div> in <div>.
|
|
|
75
75
|
This is caused by the inconsistency between the rendering result and the SSR rendering result when React executes the hydrate logic on the client side. Although the page performs normally, in complex applications, it is likely to cause problems such as DOM hierarchy confusion and style confusion.
|
|
76
76
|
|
|
77
77
|
:::info
|
|
78
|
-
For hydrate logic, please refer to [here](https://
|
|
78
|
+
For hydrate logic, please refer to [here](https://react.dev/reference/react-dom/hydrate).
|
|
79
79
|
|
|
80
80
|
:::
|
|
81
81
|
|
|
@@ -455,7 +455,7 @@ export default Page;
|
|
|
455
455
|
```
|
|
456
456
|
|
|
457
457
|
`Await` needs to be wrapped inside the `Suspense` component. The `resolve` of `Await` passes in the data acquired asynchronously by the Data Loader. When the data acquisition is completed,
|
|
458
|
-
the obtained data is rendered through the [Render Props](https://
|
|
458
|
+
the obtained data is rendered through the [Render Props](https://react.dev/reference/react/cloneElement#passing-data-with-a-render-prop) mode. When the data acquisition is in pending status, the
|
|
459
459
|
content set by the `fallback` property of the `Suspense` component will display.
|
|
460
460
|
|
|
461
461
|
|
|
@@ -41,7 +41,7 @@ function render(ui: React.ReactElement<any>, options: Options): RenderResult;
|
|
|
41
41
|
- `options`:render 可选配置。
|
|
42
42
|
- `container`:表示组件所要挂载到的 DOM 节点,默认是会创建一个 `div` 元素,并自动添加到 `document.body` 上。这个 `div` 元素就是组件要挂载的节点。默认值是 `document.body.append(document.createElement('div'))`。
|
|
43
43
|
- `baseElement`:用于指定 `queries` 中使用到的 `basename`。如果指定了 `container`, 则默认值为 `container` 的值,否则就是 `document.body`。
|
|
44
|
-
- `hydrate`:如果设置为 `true`,则会使用 [ReactDOM.hydrate](https://
|
|
44
|
+
- `hydrate`:如果设置为 `true`,则会使用 [ReactDOM.hydrate](https://zh-hans.react.dev/reference/react-dom/hydrate) 渲染组件。默认值为 `false`。
|
|
45
45
|
- `wrapper`:是一个 react 组件,可用于自定义渲染逻辑。
|
|
46
46
|
- `queries`:自定义一些自己的 `queries`。
|
|
47
47
|
|
|
@@ -74,7 +74,7 @@ Warning: Expected server HTML to contain a matching <div> in <div>.
|
|
|
74
74
|
这是 React 在客户端执行 hydrate 逻辑时,发现渲染结果与 SSR 渲染结果不一致造成的。虽然页面表现正常,但在复杂应用中,很有可能因此出现 DOM 层级混乱、样式混乱等问题。
|
|
75
75
|
|
|
76
76
|
:::info
|
|
77
|
-
关于 hydrate (注水)逻辑请参考[这里](https://
|
|
77
|
+
关于 hydrate (注水)逻辑请参考[这里](https://zh-hans.react.dev/reference/react-dom/hydrate)。
|
|
78
78
|
|
|
79
79
|
:::
|
|
80
80
|
|
|
@@ -447,7 +447,7 @@ export default Page;
|
|
|
447
447
|
```
|
|
448
448
|
|
|
449
449
|
`Await` 需要包裹在 `Suspense` 组件内部,`Await` 的 `resolve` 传入的是 Data Loader 异步获取的数据,当数据获取完成后,
|
|
450
|
-
通过 [Render Props](https://
|
|
450
|
+
通过 [Render Props](https://zh-hans.react.dev/reference/react/cloneElement#passing-data-with-a-render-prop) 模式,渲染获取到的数据。在数据的获取阶段,将展示
|
|
451
451
|
`Suspense` 组件 `fallback` 属性设置的内容。
|
|
452
452
|
|
|
453
453
|
:::warning 注意
|
package/package.json
CHANGED
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "0.0.0-next-
|
|
18
|
+
"version": "0.0.0-next-1686752256456",
|
|
19
19
|
"publishConfig": {
|
|
20
20
|
"registry": "https://registry.npmjs.org/",
|
|
21
21
|
"access": "public",
|
|
22
22
|
"provenance": true
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@modern-js/builder-doc": "0.0.0-next-
|
|
25
|
+
"@modern-js/builder-doc": "0.0.0-next-1686752256456"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"classnames": "^2",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"fs-extra": "^10",
|
|
35
35
|
"@types/node": "^16",
|
|
36
36
|
"@types/fs-extra": "^9",
|
|
37
|
-
"@modern-js/
|
|
38
|
-
"@modern-js/doc
|
|
39
|
-
"@modern-js/doc-tools": "0.0.0-next-
|
|
37
|
+
"@modern-js/doc-plugin-auto-sidebar": "0.0.0-next-1686752256456",
|
|
38
|
+
"@modern-js/builder-doc": "0.0.0-next-1686752256456",
|
|
39
|
+
"@modern-js/doc-tools": "0.0.0-next-1686752256456"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"dev": "modern dev",
|