-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
docs(cn): translate Reference/react/separating events from effects into Chinese #1167
Conversation
Size changes📦 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! 🙌 |
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” 按钮,组件应该在当前聊天界面发送一条消息。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
此处以及后面的 “‘Send 按钮’” ,烦请考虑(1)能否改为“‘发送’按钮”(2)如果确实使用英文更何时,看看是否应该统一大小写
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(3)如果使用英文,是否需要使用引号?
后文似乎有地方没有用引号,但是这几处使用了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
大小写已统一,是否使用引号是跟随原文的,不确定是否应该修改
There was a problem hiding this comment.
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>
为什么此 PR 调整了 3 个文件? |
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” 按钮,组件应该在当前聊天界面发送一条消息。 |
There was a problem hiding this comment.
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>
…ub.com:earthaYan/zh-hans.react.dev into reference/react/separating-events-from-effects
// ... | ||
``` | ||
|
||
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 是非响应式的并且必须从依赖项中删除**。 |
There was a problem hiding this comment.
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很有意义的原因。 |
There was a problem hiding this comment.
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。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
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 中传入: |
There was a problem hiding this comment.
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 被调用时刻** 的值。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看了一下,其他两个文件的变更发生在该commit,commit message 显示是合并最新的main分支到该PR的分支,但本次commit只修改了另外两个文件,猜测可能是当时在vscode上操作的时候正好发现这两处的link跟各自文章中的其他link不一致,所以顺手改了 |
No description provided.