Translate activity clean#1917
Open
OpenLucasKaka wants to merge 3 commits into
Open
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 This PR introduced no changes to the JavaScript bundle! 🙌 |
loveloki
reviewed
May 11, 2026
Collaborator
loveloki
left a comment
There was a problem hiding this comment.
如果同意建议的话直接应用就行,有不同意见在里面进行评论,记得不要 force push,提交新的 commit 来进行修改
| 通过这种方式,`Activity` 可以被视为一种渲染“后台活动”的机制。与其完全丢弃那些可能再次显示的内容,不如使用 `Activity` 来保持并恢复这些内容的 UI 和内部状态,同时确保隐藏的内容不会产生多余的副作用。 | ||
|
|
||
| [See more examples below.](#usage) | ||
| [请参阅下方的更多示例]。(#usage) |
|
|
||
| * `children`: The UI you intend to show and hide. | ||
| * `mode`: A string value of either `'visible'` or `'hidden'`. If omitted, defaults to `'visible'`. | ||
| * `children`: 你想要显示或隐藏的 UI。 |
Collaborator
There was a problem hiding this comment.
这里的 : 多了个空格,检查下其他地方是不是也有多?
| - If an Activity is rendered inside of a [ViewTransition](/reference/react/ViewTransition), and it becomes visible as a result of an update caused by [startTransition](/reference/react/startTransition), it will activate the ViewTransition's `enter` animation. If it becomes hidden, it will activate its `exit` animation. | ||
| - A *hidden* Activity that just renders text will not render anything rather than rendering hidden text, because there’s no corresponding DOM element to apply visibility changes to. For example, `<Activity mode="hidden"><ComponentThatJustReturnsText /></Activity>` will not produce any output in the DOM for `const ComponentThatJustReturnsText = () => "Hello, World!"`. `<Activity mode="visible"><ComponentThatJustReturnsText /></Activity>` will render visible text. | ||
| - 如果 Activity 被渲染在 [ViewTransition](/reference/react/ViewTransition) 内部,并且由于 [startTransition](/reference/react/startTransition) 触发的更新而变为可见,它将触发 ViewTransition 的 `enter` 动画。如果它变为隐藏,则会触发其 `exit` 动画。 | ||
| - 仅渲染文本的 `Activity` 不会渲染出任何内容,而不是渲染出“隐藏的文本”,因为没有相应的 DOM 元素可以应用可见性变化。例如,对于 `const ComponentThatJustReturnsText = () => "Hello, World!"`,执行 `<Activity mode="hidden"><ComponentThatJustReturnsText /></Activity>` 在 DOM 中不会产生任何输出。 |
| ### 预渲染可能变为可见的内容 {/*pre-rendering-content-thats-likely-to-become-visible*/} | ||
|
|
||
| So far, we've seen how Activity can hide some content that the user has interacted with, without discarding that content's ephemeral state. | ||
| 到目前为止,我们已经了解了 `Activity` 是如何在隐藏用户交互过的内容的同时,而不丢弃这些内容的瞬时状态(ephemeral state)的。 |
Collaborator
There was a problem hiding this comment.
ephemeral state 放在第一次翻译的地方,前面也有个被翻译成中文的
| 到目前为止,我们已经了解了 `Activity` 是如何在隐藏用户交互过的内容的同时,而不丢弃这些内容的瞬时状态(ephemeral state)的。 | ||
|
|
||
| But Activity boundaries can also be used to _prepare_ content that the user has yet to see for the first time: | ||
| 不仅如此,`Activity` 边界还可以用来预先**准备**那些用户尚未初次看到的内容: |
Collaborator
There was a problem hiding this comment.
Suggested change
| 不仅如此,`Activity` 边界还可以用来预先**准备**那些用户尚未初次看到的内容: | |
| 不仅如此,`Activity` 边界还可以用来预先 **准备** 那些用户尚未初次看到的内容: |
加粗的内容两边添加空格,其他地方也要改一下
| 当 `Activity` 边界在初次渲染时处于 <CodeStep step={1}>隐藏</CodeStep> 状态,其子组件虽然不会在页面上显示,但它们**仍会被渲染**。不过,它们的渲染优先级会低于可见内容,且不会挂载它们的 Effect。 | ||
|
|
||
| This _pre-rendering_ allows the children to load any code or data they need ahead of time, so that later, when the Activity boundary becomes visible, the children can appear faster with reduced loading times. | ||
| 这种“**预渲染**”允许子组件提前加载所需的任何代码或数据。这样一来,当随后 `Activity` 边界变为可见时,子组件就能以更短的加载时间实现更快的呈现。 |
Collaborator
There was a problem hiding this comment.
Suggested change
| 这种“**预渲染**”允许子组件提前加载所需的任何代码或数据。这样一来,当随后 `Activity` 边界变为可见时,子组件就能以更短的加载时间实现更快的呈现。 | |
| 这种 **预渲染** 允许子组件提前加载所需的任何代码或数据。这样一来,当随后 `Activity` 边界变为可见时,子组件就能因为更短的加载时间从而更快的呈现出来。 |
引号和加粗保留一种就行
| </Sandpack> | ||
|
|
||
| This is because `App` doesn't mount `Posts` until its tab is active. | ||
| 这是因为 `App` 组件直到 `Posts` 标签页变为活跃状态时才会挂载 `Posts` |
Collaborator
There was a problem hiding this comment.
Suggested change
| 这是因为 `App` 组件直到 `Posts` 标签页变为活跃状态时才会挂载 `Posts` | |
| 这是因为 `App` 组件直到 `Posts` 标签页变为活跃状态时才会挂载 `Posts`。 |
| - Data fetching with Suspense-enabled frameworks like [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) and [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense) | ||
| - Lazy-loading component code with [`lazy`](/reference/react/lazy) | ||
| - Reading the value of a cached Promise with [`use`](/reference/react/use) | ||
| - 使用支持 `Suspense` 的框架进行数据获取,例如[Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) 和 [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense) |
Collaborator
There was a problem hiding this comment.
Suggested change
| - 使用支持 `Suspense` 的框架进行数据获取,例如[Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) 和 [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense) | |
| - 使用支持 `Suspense` 的框架进行数据获取,例如 [Relay](https://relay.dev/docs/guided-tour/rendering/loading-states/) 和 [Next.js](https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming#streaming-with-suspense) |
| - 使用 [`use`](/reference/react/use) 读取缓存的 Promise 的值 | ||
|
|
||
| Activity **does not** detect data that is fetched inside an Effect. | ||
| `Activity` **无法**检测到在 Effect 内部获取的数据。 |
Collaborator
There was a problem hiding this comment.
Suggested change
| `Activity` **无法**检测到在 Effect 内部获取的数据。 | |
| `Activity` **无法** 检测到在 Effect 内部获取的数据。 |
| ``` | ||
|
|
||
| ...but it would also change the UI, since the `Placeholder` fallback would be displayed on the initial render. | ||
| ……但这同时也会改变 UI 表现,因为在初始渲染期间会显示 `Placeholder` 回退内容 |
Collaborator
There was a problem hiding this comment.
Suggested change
| ……但这同时也会改变 UI 表现,因为在初始渲染期间会显示 `Placeholder` 回退内容 | |
| ……但这同时也会改变 UI 表现,因为在初始渲染期间会显示 `Placeholder` 回退内容。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
已经重新从main拉去最新代码 并将review后的更改合并