@modern-js/main-doc 0.0.0-next-20221216140552 → 0.0.0-next-20221218140542

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # @modern-js/main-doc
2
2
 
3
- ## 0.0.0-next-20221216140552
3
+ ## 0.0.0-next-20221218140542
4
4
 
5
5
  ### Patch Changes
6
6
 
@@ -30,4 +30,4 @@
30
30
  - Updated dependencies [3fae2d03b]
31
31
  - Updated dependencies [df41d71ad]
32
32
  - Updated dependencies [14b712da8]
33
- - @modern-js/builder-doc@0.0.0-next-20221216140552
33
+ - @modern-js/builder-doc@0.0.0-next-20221218140542
package/package.json CHANGED
@@ -11,20 +11,20 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-next-20221216140552",
14
+ "version": "0.0.0-next-20221218140542",
15
15
  "publishConfig": {
16
16
  "registry": "https://registry.npmjs.org/",
17
17
  "access": "public"
18
18
  },
19
19
  "peerDependencies": {
20
- "@modern-js/builder-doc": "0.0.0-next-20221216140552"
20
+ "@modern-js/builder-doc": "0.0.0-next-20221218140542"
21
21
  },
22
22
  "devDependencies": {
23
23
  "ts-node": "^10",
24
24
  "fs-extra": "^10",
25
25
  "@types/node": "^16",
26
26
  "@types/fs-extra": "^9",
27
- "@modern-js/builder-doc": "0.0.0-next-20221216140552"
27
+ "@modern-js/builder-doc": "0.0.0-next-20221218140542"
28
28
  },
29
29
  "scripts": {
30
30
  "build": "npx ts-node ./scripts/sync.ts"
@@ -64,15 +64,19 @@ function App() {
64
64
  export default App;
65
65
  ```
66
66
 
67
- 因为框架默认支持 [HMR](https://webpack.js.org/concepts/hot-module-replacement/),可以看到 `http://localhost:8080/` 里的内容会自动变成 Hello Modern.js。
68
-
69
67
  删除多余的 css 文件,保持目录没有多余的文件:
70
68
 
71
69
  ```bash
72
70
  rm src/routes/index.css
73
71
  ```
74
72
 
75
- ## 使用配置
73
+ 因为框架默认支持 [HMR](https://webpack.js.org/concepts/hot-module-replacement/),可以看到 `http://localhost:8080/` 里的内容会自动更新为:
74
+
75
+ ![result](https://lf3-static.bytednsdoc.com/obj/eden-cn/zq-uylkvt/ljhwZthlaukjlkulzlp/screenshot-20221214-141909.png)
76
+
77
+ 此刻的页面还没有样式。下一章节将展开这部分的内容。
78
+
79
+ ## 开启 SSR
76
80
 
77
81
  接下来,我们修改项目中的 `modern.config.ts`,开启 SSR 能力:
78
82
 
@@ -4,7 +4,7 @@ title: 添加 Loader
4
4
 
5
5
  上一章节中,我们学习了如何添加客户端路由。
6
6
 
7
- 这一章节中,我们将会学习如何**为路由组件添加 Loader**。
7
+ 这一章节中,我们将会学习如何为**路由组件添加 Loader**。
8
8
 
9
9
  到目前为止,我们都是通过硬编码的方式,为组件提供数据。如果要从远端获取数据,通常情况下会使用 `useEffect` 来做。但在启用 SSR 的情况下,`useEffect` 是不会在服务端执行的,所以这种 SSR 只能渲染很有限的 UI。
10
10
 
@@ -216,9 +216,9 @@ export const loader = async (): Promise<LoaderData> => {
216
216
 
217
217
  function Index() {
218
218
  const { data } = useLoaderData() as LoaderData;
219
- const [{ items }, { archive, setItem }] = useModel(contacts);
219
+ const [{ items }, { archive, setItems }] = useModel(contacts);
220
220
  if (items.length === 0) {
221
- setItem(data);
221
+ setItems(data);
222
222
  }
223
223
 
224
224
  return (