Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(cn): translate Reference/react/separating events from effects into Chinese #1167

Merged

Conversation

earthaYan
Copy link
Contributor

No description provided.

@earthaYan earthaYan changed the title docsReference/react/separating events from effects docs(cn): translate Reference/react/separating events from effects into Chinese May 14, 2023
@github-actions
Copy link

github-actions bot commented May 14, 2023

Size changes

📦 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! 🙌

src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
1. Your component should automatically connect to the selected chat room.
1. When you click the "Send" button, it should send a message to the chat.
1. 组件应该自动连接选中的聊天室。
1. 每当你点击 “Send” 按钮,组件应该在当前聊天界面发送一条消息。
Copy link
Collaborator

Choose a reason for hiding this comment

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

此处以及后面的 “‘Send 按钮’” ,烦请考虑(1)能否改为“‘发送’按钮”(2)如果确实使用英文更何时,看看是否应该统一大小写

Copy link
Collaborator

Choose a reason for hiding this comment

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

(3)如果使用英文,是否需要使用引号?

后文似乎有地方没有用引号,但是这几处使用了

Copy link
Contributor Author

Choose a reason for hiding this comment

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

大小写已统一,是否使用引号是跟随原文的,不确定是否应该修改

Copy link
Collaborator

Choose a reason for hiding this comment

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

无论原文是否使用引号,翻译为中文时都建议统一格式,统一为“‘Send’ 按钮”,或“Send 按钮”。

src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
@Yucohny Yucohny added the Pending Modify 已校对,待修改阶段 label Jun 19, 2023
Co-authored-by: Yucohny <79147654+Yucohny@users.noreply.github.com>
@Yucohny
Copy link
Collaborator

Yucohny commented Jun 27, 2023

为什么此 PR 调整了 3 个文件?

src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
1. Your component should automatically connect to the selected chat room.
1. When you click the "Send" button, it should send a message to the chat.
1. 组件应该自动连接选中的聊天室。
1. 每当你点击 “Send” 按钮,组件应该在当前聊天界面发送一条消息。
Copy link
Collaborator

Choose a reason for hiding this comment

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

无论原文是否使用引号,翻译为中文时都建议统一格式,统一为“‘Send’ 按钮”,或“Send 按钮”。

Co-authored-by: Yucohny <79147654+Yucohny@users.noreply.github.com>
// ...
```

This solves the problem. Note that you had to *remove* `onConnected` from the list of your Effect's dependencies. **Effect Events are not reactive and must be omitted from dependencies.**
这个方法解决了问题。注意你必须从 Effect 依赖项中 **移除** `onConnected`。***Effect Event 是非响应式的并且必须从依赖项中删除**。
Copy link
Contributor

Choose a reason for hiding this comment

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

这里多了个星号

@@ -870,26 +870,26 @@ body {

</Sandpack>

This doesn't mean that `useEffectEvent` is *always* the correct solution. You should only apply it to the lines of code that you don't want to be reactive. In the above sandbox, you didn't want the Effect's code to be reactive with regards to `canMove`. That's why it made sense to extract an Effect Event.
这不意味着 `useEffectEvent` **总是** 正确的解决方案。你只能把它用在你不需要变成响应式的代码上。上面的 sandbox 中,你不需要 Effect 的代码响应 `canMove`。这就是提取 Effect Event很有意义的原因。
Copy link
Contributor

Choose a reason for hiding this comment

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

“Event很有意义的原因” 少了个空格


This `Timer` component keeps a `count` state variable which increases every second. The value by which it's increasing is stored in the `increment` state variable, which you can control it with the plus and minus buttons. For example, try pressing the plus button nine times, and notice that the `count` now increases each second by ten rather than by one.
`Timer` 组件保存了一个 `count` state 变量,这个变量每秒增加一次。每次增加的值存储在 `increment` state 变量中,你可以使用加减按钮控制它。例如,尝试按压加号按钮九次,注意现在 `count` 每次都增加 10 而不是 1。
Copy link
Contributor

Choose a reason for hiding this comment

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

这句和下面一句中的 “按压”,我个人觉得读起来有种怪怪的的感觉。。。我个人是认为网页上的按钮不同于现实中的按钮,网页上的按钮单纯就是 点一下,或者说 按一下。

和 chatGPT 讨论了一下,他好像也懂我的感觉:

不知道你是否有同感,或者说这点是我太敏感了哈哈


To fix the issue, instead of reading the *latest* `roomId` inside the Effect Event, make it a parameter of your Effect Event, like `connectedRoomId` below. Then pass `roomId` from your Effect by calling `onConnected(roomId)`:
为了修复这个问题,不要读取 Effect Event 内部 **最新的** `roomId`,而是如同下面的 `connectedRoomId` 一样让它成为 Effect Event 的参数。然后通过调用 `onConnected(roomId)` 将 `roomId` Effect 中传入:
Copy link
Contributor

Choose a reason for hiding this comment

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

不要读取 Effect Event 内部 最新的 roomId

上面这句这句表述有点模糊,改为:

不要在 Effect Event 里面读取 最新roomId

感觉更清晰呢

@@ -1555,11 +1555,11 @@ label { display: block; margin-top: 10px; }

<Solution>

Inside your Effect Event, `roomId` is the value *at the time Effect Event was called.*
Effect Event 内部,`roomId` 是 **Effect Event 被调用时刻** 的值。
Copy link
Contributor

Choose a reason for hiding this comment

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

这里“是”的后面多了个空格还是空格变成全角了?
在预览时看到间隔很长!

@earthaYan
Copy link
Contributor Author

为什么此 PR 调整了 3 个文件?

看了一下,其他两个文件的变更发生在该commit,commit message 显示是合并最新的main分支到该PR的分支,但本次commit只修改了另外两个文件,猜测可能是当时在vscode上操作的时候正好发现这两处的link跟各自文章中的其他link不一致,所以顺手改了

src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
src/content/learn/separating-events-from-effects.md Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Review 已翻译,待校对阶段
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants