Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
awxiaoxian2020 committed Apr 23, 2024
1 parent 71cc12a commit 70ae525
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 37 deletions.
9 changes: 0 additions & 9 deletions src/content/reference/react-dom/client/createRoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,10 @@ root.render(<App />);
* **可选** `options`:用于配置这个 React 根节点的对象。
<<<<<<< HEAD
* **可选** `onRecoverableError`:回调函数,在 React 从异常错误中恢复时自动调用。
* **可选** `identifierPrefix`:一个 React 用来配合 [`useId`](/reference/react/useId) 生成 id 的字符串前缀。在同一个页面上使用多个根节点的场景下,这将能有效避免冲突。
=======
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown, and an `errorInfo` object containing the `componentStack`.
* **optional** `onRecoverableError`: Callback called when React automatically recovers from errors. Called with an `error` React throws, and an `errorInfo` object containing the `componentStack`. Some recoverable errors may include the original error cause as `error.cause`.
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page.
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
#### 返回值 {/*returns*/}
Expand Down Expand Up @@ -1159,9 +1154,6 @@ root.render(<App />);
---
<<<<<<< HEAD
### 我得到了一个异常报错信息:“目标容器不是一个 DOM 元素(Target container is not a DOM element)” {/*im-getting-an-error-target-container-is-not-a-dom-element*/}
=======
### I'm getting an error: "You passed a second argument to root.render" {/*im-getting-an-error-you-passed-a-second-argument-to-root-render*/}
A common mistake is to pass the options for `createRoot` to `root.render(...)`:
Expand All @@ -1185,7 +1177,6 @@ root.render(<App />);
---
### I'm getting an error: "Target container is not a DOM element" {/*im-getting-an-error-target-container-is-not-a-dom-element*/}
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
这个异常错误即字面意思,你传递给 `createRoot` 的内容不是一个 DOM 元素。
Expand Down
9 changes: 0 additions & 9 deletions src/content/reference/react-dom/client/hydrateRoot.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ React 将会连接到内部有 `domNode` 的 HTML 上,然后接管其中的 `d
* **可选** `options`:一个包含此 React 根元素选项的对象。
<<<<<<< HEAD
* **可选** `onRecoverableError`:当 React 自动从错误中恢复时调用的回调函数。
* **可选** `identifierPrefix`:字符串前缀,用于标识由 [`useId`](/reference/react/useId) 生成的 ID ,可以避免在同一页面上使用多个 React 根元素时出现冲突。必须与服务端使用的前缀相同。
=======
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onCaughtError`: Callback called when React catches an error in an Error Boundary. Called with the `error` caught by the Error Boundary, and an `errorInfo` object containing the `componentStack`.
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `onUncaughtError`: Callback called when an error is thrown and not caught by an Error Boundary. Called with the `error` that was thrown and an `errorInfo` object containing the `componentStack`.
* **optional** `onRecoverableError`: Callback called when React automatically recovers from errors. Called with the `error` React throws, and an `errorInfo` object containing the `componentStack`. Some recoverable errors may include the original error cause as `error.cause`.
* **optional** `identifierPrefix`: A string prefix React uses for IDs generated by [`useId`.](/reference/react/useId) Useful to avoid conflicts when using multiple roots on the same page. Must be the same prefix as used on the server.
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
#### 返回值 {/*returns*/}
Expand Down Expand Up @@ -379,9 +374,6 @@ export default function App({counter}) {
</Sandpack>
<<<<<<< HEAD
在 hydrate 过的根组件上调用 `root.render` 是不常见的。通常情况下,你可以在组件的内部 [更新 state](/reference/react/useState)。
=======
It is uncommon to call [`root.render`](#root-render) on a hydrated root. Usually, you'll [update state](/reference/react/useState) inside one of the components instead.
### Show a dialog for uncaught errors {/*show-a-dialog-for-uncaught-errors*/}
Expand Down Expand Up @@ -1206,4 +1198,3 @@ root.render(App, {onUncaughtError});
// ✅ Correct: pass options to createRoot.
const root = hydrateRoot(container, <App />, {onUncaughtError});
```
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
6 changes: 1 addition & 5 deletions src/content/reference/react/Suspense.md
Original file line number Diff line number Diff line change
Expand Up @@ -1741,11 +1741,7 @@ function Router() {
// ...
```
<<<<<<< HEAD
这告诉 React 此 state Transition 是不紧急的,最好继续显示上一页,而不是隐藏任何已经显示的内容。现在点击按钮并等待 `Biography` 加载:
=======
This tells React that the state transition is not urgent, and it's better to keep showing the previous page instead of hiding any already revealed content. Now clicking the button "waits" for the `Biography` to load:
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
这告诉 React 这个状态转移是不紧急的,最好继续显示上一页,而不是隐藏任何已经显示的内容。现在点击按钮并等待 `Biography` 加载:
<Sandpack>
Expand Down
15 changes: 1 addition & 14 deletions src/content/reference/react/useDeferredValue.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,37 +36,24 @@ function SearchPage() {

#### 参数 {/*parameters*/}

<<<<<<< HEAD
* `value`:你想延迟的值,可以是任何类型。
=======
* `value`: The value you want to defer. It can have any type.
* `value`: 你想延迟的值,可以是任何类型。
* <CanaryBadge title="This feature is only available in the Canary channel" /> **optional** `initialValue`: A value to use during the initial render of a component. If this option is omitted, `useDeferredValue` will not defer during the initial render, because there's no previous version of `value` that it can render instead.

>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd
#### 返回值 {/*returns*/}

<<<<<<< HEAD
在组件的初始渲染期间,返回的延迟值将与你提供的值相同。但是在组件更新时,React 将会先尝试使用旧值进行重新渲染(因此它将返回旧值),然后再在后台使用新值进行另一个重新渲染(这时它将返回更新后的值)。
=======
- `currentValue`: During the initial render, the returned deferred value will be the same as the value you provided. During updates, React will first attempt a re-render with the old value (so it will return the old value), and then try another re-render in the background with the new value (so it will return the updated value).

<Canary>

In the latest React Canary versions, `useDeferredValue` returns the `initialValue` on initial render, and schedules a re-render in the background with the `value` returned.

</Canary>
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd

#### 注意事项 {/*caveats*/}

<<<<<<< HEAD
- 你应该向 `useDeferredValue` 传递原始值(如字符串和数字)或在渲染之外创建的对象。如果你在渲染期间创建了一个新对象,并立即将其传递给 `useDeferredValue`,那么每次渲染时这个对象都会不同,这将导致后台不必要的重新渲染。
=======
- When an update is inside a Transition, `useDeferredValue` always returns the new `value` and does not spawn a deferred render, since the update is already deferred.

- The values you pass to `useDeferredValue` should either be primitive values (like strings and numbers) or objects created outside of rendering. If you create a new object during rendering and immediately pass it to `useDeferredValue`, it will be different on every render, causing unnecessary background re-renders.
>>>>>>> 07cbd001f936c22f731e5741e9853ffcdfb3fedd

-`useDeferredValue` 接收到与之前不同的值(使用 [`Object.is`](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/is) 进行比较)时,除了当前渲染(此时它仍然使用旧值),它还会安排一个后台重新渲染。这个后台重新渲染是可以被中断的,如果 `value` 有新的更新,React 会从头开始重新启动后台渲染。举个例子,如果用户在输入框中的输入速度比接收延迟值的图表重新渲染的速度快,那么图表只会在用户停止输入后重新渲染。

Expand Down

0 comments on commit 70ae525

Please sign in to comment.