Skip to content

Translate activity clean#1917

Open
OpenLucasKaka wants to merge 3 commits into
reactjs:mainfrom
OpenLucasKaka:translate-activity-clean
Open

Translate activity clean#1917
OpenLucasKaka wants to merge 3 commits into
reactjs:mainfrom
OpenLucasKaka:translate-activity-clean

Conversation

@OpenLucasKaka
Copy link
Copy Markdown

已经重新从main拉去最新代码 并将review后的更改合并

@vercel
Copy link
Copy Markdown

vercel Bot commented May 11, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
zh-hans-react-dev Ready Ready Preview, Comment May 11, 2026 8:56am

Request Review

@github-actions
Copy link
Copy Markdown

Size changes

Details

📦 Next.js Bundle Analysis for react-dev

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

Copy link
Copy Markdown
Collaborator

@loveloki loveloki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果同意建议的话直接应用就行,有不同意见在里面进行评论,记得不要 force push,提交新的 commit 来进行修改

通过这种方式,`Activity` 可以被视为一种渲染“后台活动”的机制。与其完全丢弃那些可能再次显示的内容,不如使用 `Activity` 来保持并恢复这些内容的 UI 和内部状态,同时确保隐藏的内容不会产生多余的副作用。

[See more examples below.](#usage)
[请参阅下方的更多示例]。(#usage)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个试一下,是不是破坏链接了?放在里面吧


* `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
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里的 多了个空格,检查下其他地方是不是也有多?

- 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 中不会产生任何输出。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里丢了一个例子,添加上

### 预渲染可能变为可见的内容 {/*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)的。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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` 边界还可以用来预先**准备**那些用户尚未初次看到的内容:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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` 边界变为可见时,子组件就能以更短的加载时间实现更快的呈现。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
这种**预渲染**允许子组件提前加载所需的任何代码或数据。这样一来,当随后 `Activity` 边界变为可见时,子组件就能以更短的加载时间实现更快的呈现
这种 **预渲染** 允许子组件提前加载所需的任何代码或数据。这样一来,当随后 `Activity` 边界变为可见时,子组件就能因为更短的加载时间从而更快的呈现出来

引号和加粗保留一种就行

</Sandpack>

This is because `App` doesn't mount `Posts` until its tab is active.
这是因为 `App` 组件直到 `Posts` 标签页变为活跃状态时才会挂载 `Posts`
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 内部获取的数据。
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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` 回退内容
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
……但这同时也会改变 UI 表现,因为在初始渲染期间会显示 `Placeholder` 回退内容
……但这同时也会改变 UI 表现,因为在初始渲染期间会显示 `Placeholder` 回退内容

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants