Skip to content

Commit a33110e

Browse files
authored
fix conflict
1 parent ce23faf commit a33110e

6 files changed

+2
-43
lines changed

Diff for: src/content/learn/build-a-react-app-from-scratch.md

-4
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,7 @@ Rsbuild 内置了对 React 特性的支持,如快速刷新、JSX、TypeScript
6565

6666
#### React Native 的 Metro {/*react-native*/}
6767

68-
<<<<<<< HEAD
6968
如果你从头开始使用 React Native,你将需要使用 [Metro](https://metrobundler.dev/), 这是 React Native 的 JavaScript 打包工具。Metro 支持 iOS 和 Android 等平台的打包,但与这里提到的工具相比,它缺少许多功能。除非你的项目需要 React Native 支持,否则我们建议从 Vite、Parcel 或 Rsbuild 开始。
70-
=======
71-
If you're starting from scratch with React Native you'll need to use [Metro](https://metrobundler.dev/), the JavaScript bundler for React Native. Metro supports bundling for platforms like iOS and Android, but lacks many features when compared to the tools here. We recommend starting with Vite, Parcel, or Rsbuild unless your project requires React Native support.
72-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
7369

7470
</Note>
7571

Diff for: src/content/learn/reusing-logic-with-custom-hooks.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -1333,11 +1333,7 @@ export function useOnlineStatus() {
13331333
13341334
在上述示例中,`useOnlineStatus` 借助一组 [`useState`](/reference/react/useState) 和 [`useEffect`](/reference/react/useEffect) 实现。但这不是最好的解决方案。它有许多边界用例没有考虑到。例如,它认为当组件加载时,`isOnline` 已经为 `true`,但是如果网络已经离线的话这就是错误的。你可以使用浏览器的 [`navigator.onLine`](https://developer.mozilla.org/en-US/docs/Web/API/Navigator/onLine) API 来检查,但是在生成初始 HTML 的服务端直接使用它是没用的。简而言之这段代码可以改进。
13351335
1336-
<<<<<<< HEAD
1337-
幸运的是,React 18 包含了一个叫做 [`useSyncExternalStore`](/reference/react/useSyncExternalStore) 的专用 API,它可以解决你所有这些问题。这里展示了如何利用这个新 API 来重写你的 `useOnlineStatus` Hook:
1338-
=======
1339-
React includes a dedicated API called [`useSyncExternalStore`](/reference/react/useSyncExternalStore) which takes care of all of these problems for you. Here is your `useOnlineStatus` Hook, rewritten to take advantage of this new API:
1340-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
1336+
React 包含了一个叫做 [`useSyncExternalStore`](/reference/react/useSyncExternalStore) 的专用 API,它可以解决你所有这些问题。这里展示了如何利用这个新 API 来重写你的 `useOnlineStatus` Hook:
13411337
13421338
<Sandpack>
13431339

Diff for: src/content/learn/tutorial-tic-tac-toe.md

-4
Original file line numberDiff line numberDiff line change
@@ -2247,11 +2247,7 @@ body {
22472247
22482248
</Sandpack>
22492249
2250-
<<<<<<< HEAD
22512250
当你在传递给 `map` 的函数中遍历 `history` 数组时,`squares` 参数遍历 `history` 的每个元素,`move` 参数遍历每个数组索引:`0``1``2`……(在大多数情况下,你需要数组元素,但要渲染落子列表,你只需要索引。)
2252-
=======
2253-
As you iterate through the `history` array inside the function you passed to `map`, the `squares` argument goes through each element of `history`, and the `move` argument goes through each array index: `0`, `1`, `2`, …. (In most cases, you'd need the actual array elements, but to render a list of moves you will only need indexes.)
2254-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
22552251
22562252
对于井字棋游戏历史中的每一步,你创建一个列表项 `<li>`,其中包含一个按钮 `<button>`。该按钮有一个 `onClick` 处理程序,它调用一个名为 `jumpTo` 的函数(你尚未实现)。
22572253

Diff for: src/content/reference/react/Component.md

-5
Original file line numberDiff line numberDiff line change
@@ -1298,12 +1298,7 @@ class ErrorBoundary extends React.Component {
12981298
// 在 div 中(由 APP 创建)
12991299
// 在 App 中
13001300
info.componentStack,
1301-
<<<<<<< HEAD
1302-
// 仅在 react@canary 版本可用
13031301
// 警告:Owner Stack 在生产中不可用
1304-
=======
1305-
// Warning: `captureOwnerStack` is not available in production.
1306-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
13071302
React.captureOwnerStack(),
13081303
);
13091304
}

Diff for: src/content/reference/react/StrictMode.md

-7
Original file line numberDiff line numberDiff line change
@@ -86,17 +86,10 @@ root.render(
8686

8787
严格模式启用了以下仅在开发环境下有效的行为:
8888

89-
<<<<<<< HEAD
9089
- 组件将 [重新渲染一次](#fixing-bugs-found-by-double-rendering-in-development) 以查找由于非纯渲染而引起的错误。
9190
- 组件将 [重新运行一次 Effect](#fixing-bugs-found-by-re-running-effects-in-development) 以查找由于缺少 Effect 清理而引起的错误。
9291
- 组件将 [额外重新运行一次 refs 回调](#fixing-bugs-found-by-re-running-ref-callbacks-in-development) 以查找由于缺少 ref 清理函数而引起的错误。
9392
- 组件将被 [检查是否使用了已弃用的 API](#fixing-deprecation-warnings-enabled-by-strict-mode)
94-
=======
95-
- Your components will [re-render an extra time](#fixing-bugs-found-by-double-rendering-in-development) to find bugs caused by impure rendering.
96-
- Your components will [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) to find bugs caused by missing Effect cleanup.
97-
- Your components will [re-run ref callbacks an extra time](#fixing-bugs-found-by-re-running-ref-callbacks-in-development) to find bugs caused by missing ref cleanup.
98-
- Your components will [be checked for usage of deprecated APIs.](#fixing-deprecation-warnings-enabled-by-strict-mode)
99-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
10093

10194
**所有这些检查仅在开发环境中进行,不会影响生产构建。**
10295

Diff for: src/content/reference/react/useSyncExternalStore.md

+1-18
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,7 @@ function getSnapshot() {
407407
408408
```js {2-5}
409409
function ChatIndicator() {
410-
<<<<<<< HEAD
411-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
412-
413410
// 🚩 总是不同的函数,所以 React 每次重新渲染都会重新订阅
414-
=======
415-
// 🚩 Always a different function, so React will resubscribe on every re-render
416-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
417411
function subscribe() {
418412
// ...
419413
}
@@ -427,18 +421,13 @@ function ChatIndicator() {
427421
如果重新渲染时你传一个不同的 `subscribe` 函数,React 会重新订阅你的 store。如果这造成了性能问题,因而你想避免重新订阅,就把 `subscribe` 函数移到外面:
428422
429423
```js {1-4}
430-
//Always the same function, so React won't need to resubscribe
424+
//总是相同的函数,所以 React 不需要重新订阅
431425
function subscribe() {
432426
// ...
433427
}
434428

435-
<<<<<<< HEAD
436-
// ✅ 总是相同的函数,所以 React 不需要重新订阅
437-
function subscribe() {
438-
=======
439429
function ChatIndicator() {
440430
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
441-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
442431
// ...
443432
}
444433
```
@@ -447,13 +436,7 @@ function ChatIndicator() {
447436
448437
```js {2-5}
449438
function ChatIndicator({ userId }) {
450-
<<<<<<< HEAD
451-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
452-
453439
// ✅ 只要 userId 不变,都是同一个函数
454-
=======
455-
// ✅ Same function as long as userId doesn't change
456-
>>>>>>> 6ead1fae680c3ead42614f62ffae51a57f559f4f
457440
const subscribe = useCallback(() => {
458441
// ...
459442
}, [userId]);

0 commit comments

Comments
 (0)