Skip to content

Commit 1d4f7b5

Browse files
committed
fix
1 parent 13d4bee commit 1d4f7b5

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/content/blog/2025/02/14/sunsetting-create-react-app.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ export default function App() {
154154

155155
### 数据获取 {/*data-fetching*/}
156156

157-
React 应用开发中的另一个常见问题是数据获取。Create React App 并没有内置特定的数据获取解决方案。如果你刚刚入门,常见的做法是在 副作用(effect) 中使用 fetch 方法来加载数据。
157+
React 应用开发中的另一个常见问题是数据获取。Create React App 并没有内置特定的数据获取解决方案。如果你刚刚入门,常见的做法是在副作用中使用 fetch 方法来加载数据。
158158

159159
但是,这样做意味着数据是在组件渲染之后才获取的,这可能会导致 网络瀑布流问题(network waterfalls)。网络瀑布流问题的产生是因为数据是在应用程序渲染时才开始获取的,而不是在代码下载的同时并行获取数据:
160160

@@ -177,7 +177,7 @@ export default function Dashboard() {
177177
}
178178
```
179179

180-
在 副作用(effect) 中获取数据意味着用户需要等待更长时间才能看到内容,即使这些数据本可以更早地获取。为了解决这个问题,你可以使用一些数据获取库,例如:[React Query](https://react-query.tanstack.com/)[SWR](https://swr.vercel.app/)[Apollo](https://www.apollographql.com/docs/react)[Relay](https://relay.dev/),这些库提供了预取数据的功能,使得请求可以在组件渲染之前就开始,从而减少用户等待时间并提升性能
180+
在副作用中获取数据意味着用户需要等待更长时间才能看到内容,即使这些数据本可以更早地获取。为了解决这个问题,你可以使用一些数据获取库,例如:[React Query](https://react-query.tanstack.com/)[SWR](https://swr.vercel.app/)[Apollo](https://www.apollographql.com/docs/react)[Relay](https://relay.dev/),这些库提供了预取数据的功能,使得请求可以在组件渲染之前就开始,从而减少用户等待时间并提升性能
181181

182182
这些库在与路由的 "loader" 模式 集成时效果最佳,可以在路由级别指定数据依赖关系,从而使路由器能够优化数据获取:
183183

0 commit comments

Comments
 (0)