Skip to content

Commit 62a3c08

Browse files
merging all conflicts
2 parents 4e55207 + 5138e60 commit 62a3c08

12 files changed

+60
-63
lines changed

postcss.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ module.exports = {
1717
},
1818
},
1919
},
20-
}
20+
};

public/js/jsfiddle-integration-babel.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
// Do not delete or move this file.
66
// Many fiddles reference it so we have to keep it here.
7-
(function() {
7+
(function () {
88
var tag = document.querySelector(
99
'script[type="application/javascript;version=1.7"]'
1010
);
1111
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
12-
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
12+
alert(
13+
'Bad JSFiddle configuration, please fork the original React JSFiddle'
14+
);
1315
}
1416
tag.setAttribute('type', 'text/babel');
1517
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');

public/js/jsfiddle-integration.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44

55
// Do not delete or move this file.
66
// Many fiddles reference it so we have to keep it here.
7-
(function() {
7+
(function () {
88
var tag = document.querySelector(
99
'script[type="application/javascript;version=1.7"]'
1010
);
1111
if (!tag || tag.textContent.indexOf('window.onload=function(){') !== -1) {
12-
alert('Bad JSFiddle configuration, please fork the original React JSFiddle');
12+
alert(
13+
'Bad JSFiddle configuration, please fork the original React JSFiddle'
14+
);
1315
}
1416
tag.setAttribute('type', 'text/jsx;harmony=true');
1517
tag.textContent = tag.textContent.replace(/^\/\/<!\[CDATA\[/, '');

src/components/MDX/Sandpack/template.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ root.render(
2828
eject: 'react-scripts eject',
2929
},
3030
dependencies: {
31-
react: '19.0.0-rc-3edc000d-20240926',
32-
'react-dom': '19.0.0-rc-3edc000d-20240926',
31+
react: '^19.1.0',
32+
'react-dom': '^19.1.0',
3333
'react-scripts': '^5.0.0',
3434
},
3535
},

src/content/community/meetups.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
8181
* [Thessaloniki](https://www.meetup.com/Thessaloniki-ReactJS-Meetup/)
8282

8383
## India {/*india*/}
84-
* [Ahmedabad](https://www.meetup.com/react-ahmedabad/)
84+
* [Ahmedabad](https://reactahmedabad.dev/)
8585
* [Bangalore (React)](https://www.meetup.com/ReactJS-Bangalore/)
8686
* [Bangalore (React Native)](https://www.meetup.com/React-Native-Bangalore-Meetup)
8787
* [Chennai](https://www.linkedin.com/company/chennaireact)
@@ -169,6 +169,7 @@ Do you have a local React.js meetup? Add it here! (Please keep the list alphabet
169169
* [Cleveland, OH - ReactJS](https://www.meetup.com/Cleveland-React/)
170170
* [Columbus, OH - ReactJS](https://www.meetup.com/ReactJS-Columbus-meetup/)
171171
* [Dallas, TX - ReactJS](https://www.meetup.com/ReactDallas/)
172+
* [Denver, CO - React Denver](https://reactdenver.com/)
172173
* [Detroit, MI - Detroit React User Group](https://www.meetup.com/Detroit-React-User-Group/)
173174
* [Indianapolis, IN - React.Indy](https://www.meetup.com/React-Indy)
174175
* [Irvine, CA - ReactJS](https://www.meetup.com/ReactJS-OC/)

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

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

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

68+
<<<<<<< HEAD
6869
如果你从头开始使用 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+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
6973
7074
</Note>
7175

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

+4
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,11 @@ 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
13361337
幸运的是,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+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
13371341
13381342
<Sandpack>
13391343

src/content/learn/tutorial-tic-tac-toe.md

+4
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,11 @@ body {
22472247
22482248
</Sandpack>
22492249
2250+
<<<<<<< HEAD
22502251
当你在传递给 `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+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
22512255
22522256
对于井字棋游戏历史中的每一步,你创建一个列表项 `<li>`,其中包含一个按钮 `<button>`。该按钮有一个 `onClick` 处理程序,它调用一个名为 `jumpTo` 的函数(你尚未实现)。
22532257

src/content/reference/react/Component.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,7 @@ button { margin-left: 10px; }
12731273

12741274
要实现错误边界组件,你需要提供 [`static getDerivedStateFromError`](#static-getderivedstatefromerror),它允许你更新状态以响应错误并向用户显示错误消息。你还可以选择实现 [`componentDidCatch`](#componentdidcatch) 来添加一些额外的逻辑,例如将错误添加到分析服务。
12751275

1276-
<CanaryBadge /> With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development.
1276+
With [`captureOwnerStack`](/reference/react/captureOwnerStack) you can include the Owner Stack during development.
12771277

12781278
```js {9-12,14-27}
12791279
import * as React from 'react';
@@ -1298,8 +1298,12 @@ class ErrorBoundary extends React.Component {
12981298
// 在 div 中(由 APP 创建)
12991299
// 在 App 中
13001300
info.componentStack,
1301+
<<<<<<< HEAD
13011302
// 仅在 react@canary 版本可用
13021303
// 警告:Owner Stack 在生产中不可用
1304+
=======
1305+
// Warning: `captureOwnerStack` is not available in production.
1306+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
13031307
React.captureOwnerStack(),
13041308
);
13051309
}

src/content/reference/react/StrictMode.md

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

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

89+
<<<<<<< HEAD
8990
- 组件将 [重新渲染一次](#fixing-bugs-found-by-double-rendering-in-development) 以查找由于非纯渲染而引起的错误。
9091
- 组件将 [重新运行一次 Effect](#fixing-bugs-found-by-re-running-effects-in-development) 以查找由于缺少 Effect 清理而引起的错误。
9192
- 组件将 [额外重新运行一次 refs 回调](#fixing-bugs-found-by-re-running-ref-callbacks-in-development) 以查找由于缺少 ref 清理函数而引起的错误。
9293
- 组件将被 [检查是否使用了已弃用的 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+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
93100
94101
**所有这些检查仅在开发环境中进行,不会影响生产构建。**
95102

@@ -124,7 +131,7 @@ function App() {
124131

125132
<Note>
126133

127-
When `StrictMode` is enabled for a part of the app, React will only enable behaviors that are possible in production. For example, if `<StrictMode>` is not enabled at the root of the app, it will not [re-run Effects an extra time](#fixing-bugs-found-by-cleaning-up-and-re-attaching-dom-refs-in-development) on initial mount, since this would cause child effects to double fire without the parent effects, which cannot happen in production.
134+
When `StrictMode` is enabled for a part of the app, React will only enable behaviors that are possible in production. For example, if `<StrictMode>` is not enabled at the root of the app, it will not [re-run Effects an extra time](#fixing-bugs-found-by-re-running-effects-in-development) on initial mount, since this would cause child effects to double fire without the parent effects, which cannot happen in production.
128135

129136
</Note>
130137

src/content/reference/react/captureOwnerStack.md

-48
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,6 @@ createRoot(document.createElement('div'), {
120120
);
121121
```
122122

123-
```json package.json hidden
124-
{
125-
"dependencies": {
126-
"react": "canary",
127-
"react-dom": "canary",
128-
"react-scripts": "latest"
129-
},
130-
"scripts": {
131-
"start": "react-scripts start",
132-
"build": "react-scripts build",
133-
"test": "react-scripts test --env=jsdom",
134-
"eject": "react-scripts eject"
135-
}
136-
}
137-
```
138-
139123
```html public/index.html hidden
140124
<!DOCTYPE html>
141125
<html lang="en">
@@ -351,22 +335,6 @@ const container = document.getElementById("root");
351335
createRoot(container).render(<App />);
352336
```
353337

354-
```json package.json hidden
355-
{
356-
"dependencies": {
357-
"react": "canary",
358-
"react-dom": "canary",
359-
"react-scripts": "latest"
360-
},
361-
"scripts": {
362-
"start": "react-scripts start",
363-
"build": "react-scripts build",
364-
"test": "react-scripts test --env=jsdom",
365-
"eject": "react-scripts eject"
366-
}
367-
}
368-
```
369-
370338
```js src/App.js
371339
function Component() {
372340
return <button onClick={() => console.error('Some console error')}>Trigger console.error()</button>;
@@ -411,22 +379,6 @@ export default function App() {
411379
}
412380
```
413381

414-
```json package.json hidden
415-
{
416-
"dependencies": {
417-
"react": "canary",
418-
"react-dom": "canary",
419-
"react-scripts": "latest"
420-
},
421-
"scripts": {
422-
"start": "react-scripts start",
423-
"build": "react-scripts build",
424-
"test": "react-scripts test --env=jsdom",
425-
"eject": "react-scripts eject"
426-
}
427-
}
428-
```
429-
430382
</Sandpack>
431383

432384
### `captureOwnerStack` is not available {/*captureownerstack-is-not-available*/}

src/content/reference/react/useSyncExternalStore.md

+22-5
Original file line numberDiff line numberDiff line change
@@ -405,43 +405,60 @@ function getSnapshot() {
405405
406406
这里的 `subscribe` 函数是在组件 **内部** 定义的,所以它每次渲染都不同:
407407
408-
```js {4-7}
408+
```js {2-5}
409409
function ChatIndicator() {
410+
<<<<<<< HEAD
410411
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
411412

412413
// 🚩 总是不同的函数,所以 React 每次重新渲染都会重新订阅
414+
=======
415+
// 🚩 Always a different function, so React will resubscribe on every re-render
416+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
413417
function subscribe() {
414418
// ...
415419
}
420+
421+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
416422

417423
// ...
418424
}
419425
```
420426
421427
如果重新渲染时你传一个不同的 `subscribe` 函数,React 会重新订阅你的 store。如果这造成了性能问题,因而你想避免重新订阅,就把 `subscribe` 函数移到外面:
422428
423-
```js {6-9}
424-
function ChatIndicator() {
425-
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
429+
```js {1-4}
430+
// ✅ Always the same function, so React won't need to resubscribe
431+
function subscribe() {
426432
// ...
427433
}
428434

435+
<<<<<<< HEAD
429436
// ✅ 总是相同的函数,所以 React 不需要重新订阅
430437
function subscribe() {
438+
=======
439+
function ChatIndicator() {
440+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
441+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
431442
// ...
432443
}
433444
```
434445
435446
或者,把 `subscribe` 包在 [`useCallback`](/reference/react/useCallback) 里面以便只在某些参数改变时重新订阅:
436447
437-
```js {4-8}
448+
```js {2-5}
438449
function ChatIndicator({ userId }) {
450+
<<<<<<< HEAD
439451
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
440452

441453
// ✅ 只要 userId 不变,都是同一个函数
454+
=======
455+
// ✅ Same function as long as userId doesn't change
456+
>>>>>>> 5138e605225b24d25701a1a1f68daa90499122a4
442457
const subscribe = useCallback(() => {
443458
// ...
444459
}, [userId]);
460+
461+
const isOnline = useSyncExternalStore(subscribe, getSnapshot);
445462

446463
// ...
447464
}

0 commit comments

Comments
 (0)