Skip to content

Commit 4f098c8

Browse files
merging all conflicts
2 parents 43f3abb + fc29603 commit 4f098c8

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,15 @@ This error message will only be shown once per install.
6565

6666
针对现有应用,以下指南将协助你迁移至构建工具:
6767

68+
<<<<<<< HEAD
6869
* [Create React App 到 Vite 迁移指南](https://www.robinwieruch.de/vite-create-react-app/)
6970
* [Create React App 到 Parcel 迁移指南](https://stackoverflow.com/a/49605484)
7071
* [Create React App 到 Rsbuild 迁移指南](https://rsbuild.dev/guide/migration/cra)
72+
=======
73+
* [Vite Create React App migration guide](https://www.robinwieruch.de/vite-create-react-app/)
74+
* [Parcel Create React App migration guide](https://parceljs.org/migration/cra/)
75+
* [Rsbuild Create React App migration guide](https://rsbuild.dev/guide/migration/cra)
76+
>>>>>>> fc29603434ec04621139738f4740caed89d659a7
7177
7278
为帮助开发者快速上手 Vite、Parcel 或 Rsbuild,我们新增了 [从零开始构建 React 应用](/learn/build-a-react-app-from-scratch) 文档。
7379

src/content/learn/manipulating-the-dom-with-refs.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,12 +646,21 @@ button {
646646

647647
<Recap>
648648

649+
<<<<<<< HEAD
649650
- Refs 是一个通用概念,但大多数情况下你会使用它们来保存 DOM 元素。
650651
- 你通过传递 `<div ref={myRef}>` 指示 React 将 DOM 节点放入 `myRef.current`
651652
- 通常,你会将 refs 用于非破坏性操作,例如聚焦、滚动或测量 DOM 元素。
652653
- 默认情况下,组件不暴露其 DOM 节点。 你可以通过使用 `forwardRef` 并将第二个 `ref` 参数传递给特定节点来暴露 DOM 节点。
653654
- 避免更改由 React 管理的 DOM 节点。
654655
- 如果你确实修改了 React 管理的 DOM 节点,请修改 React 没有理由更新的部分。
656+
=======
657+
- Refs are a generic concept, but most often you'll use them to hold DOM elements.
658+
- You instruct React to put a DOM node into `myRef.current` by passing `<div ref={myRef}>`.
659+
- Usually, you will use refs for non-destructive actions like focusing, scrolling, or measuring DOM elements.
660+
- A component doesn't expose its DOM nodes by default. You can opt into exposing a DOM node by using the `ref` prop.
661+
- Avoid changing DOM nodes managed by React.
662+
- If you do modify DOM nodes managed by React, modify parts that React has no reason to update.
663+
>>>>>>> fc29603434ec04621139738f4740caed89d659a7
655664
656665
</Recap>
657666

@@ -1051,7 +1060,11 @@ img {
10511060

10521061
<Hint>
10531062

1063+
<<<<<<< HEAD
10541064
你需要 `forwardRef` 来主动从你自己的组件中暴露一个 DOM 节点,比如 `SearchInput`
1065+
=======
1066+
You'll need to pass `ref` as a prop to opt into exposing a DOM node from your own component like `SearchInput`.
1067+
>>>>>>> fc29603434ec04621139738f4740caed89d659a7
10551068
10561069
</Hint>
10571070

@@ -1136,6 +1149,7 @@ export default function SearchButton({ onClick }) {
11361149
```
11371150

11381151
```js src/SearchInput.js
1152+
<<<<<<< HEAD
11391153
import { forwardRef } from 'react';
11401154

11411155
export default forwardRef(
@@ -1148,6 +1162,16 @@ export default forwardRef(
11481162
);
11491163
}
11501164
);
1165+
=======
1166+
export default function SearchInput({ ref }) {
1167+
return (
1168+
<input
1169+
ref={ref}
1170+
placeholder="Looking for something?"
1171+
/>
1172+
);
1173+
}
1174+
>>>>>>> fc29603434ec04621139738f4740caed89d659a7
11511175
```
11521176

11531177
```css

src/content/reference/react-dom/client/hydrateRoot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ The <CodeStep step={1}>onCaughtError</CodeStep> option is a function called with
402402
1. The <CodeStep step={2}>error</CodeStep> that was thrown.
403403
2. An <CodeStep step={3}>errorInfo</CodeStep> object that contains the <CodeStep step={4}>componentStack</CodeStep> of the error.
404404
405-
Together with `onUncaughtError` and `onRecoverableError`, you can can implement your own error reporting system:
405+
Together with `onUncaughtError` and `onRecoverableError`, you can implement your own error reporting system:
406406
407407
<Sandpack>
408408

src/content/reference/react-dom/components/form.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ export default function App() {
214214
]);
215215
async function sendMessage(formData) {
216216
const sentMessage = await deliverMessage(formData.get("message"));
217-
setMessages([...messages, { text: sentMessage }]);
217+
setMessages((messages) => [...messages, { text: sentMessage }]);
218218
}
219219
return <Thread messages={messages} sendMessage={sendMessage} />;
220220
}

src/content/reference/react-dom/components/style.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ React 可以将 `<style>` 组件移动到文档的 `<head>` 中,去重相同
5151

5252
这种特殊处理带来两个注意事项:
5353

54+
<<<<<<< HEAD
5455
* 在样式被渲染后,React 将忽略属性的更改(React 在开发环境中会对这种情况发出警告)。
5556
* 即使渲染它的组件已被卸载,React 也可能将样式保留在 DOM 中。
57+
=======
58+
* React will ignore changes to props after the style has been rendered. (React will issue a warning in development if this happens.)
59+
* React will drop all extraneous props when using the `precedence` prop (beyond `href` and `precedence`).
60+
* React may leave the style in the DOM even after the component that rendered it has been unmounted.
61+
>>>>>>> fc29603434ec04621139738f4740caed89d659a7
5662
5763
---
5864

0 commit comments

Comments
 (0)