-
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/memo into Chinese #1160
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! 🙌 |
Co-authored-by: fwqaaq <fwqaaq@gmail.com>
src/content/reference/react/memo.md
Outdated
|
||
</DeepDive> | ||
|
||
--- | ||
|
||
### Updating a memoized component using state {/*updating-a-memoized-component-using-state*/} | ||
### 使用 state 更新 memoized(记忆化)组件 {/*updating-a-memoized-component-using-state*/} |
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.
前文是使用的“记忆化(memoized)”,这里是使用的的“memoized(记忆化)”,这种地方需要统一一下,建议使用“记忆化(memoized)”,用 memoized 解释“记忆化”
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.
嗯,这里我统一一下
src/content/reference/react/memo.md
Outdated
|
||
When you use `memo`, your component re-renders whenever any prop is not *shallowly equal* to what it was previously. This means that React compares every prop in your component with its previous value using the [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) comparison. Note that `Object.is(3, 3)` is `true`, but `Object.is({}, {})` is `false`. | ||
当你使用 `memo` 时,只要任何一个 prop 与先前的值不是 **浅层相等** 的话,你的组件就会重新渲染。这意味着 React 会使用 [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) 比较将组件中的每个 prop 与其先前的值进行比较。注意,`Object.is(3, 3)` 为 `true`,但 `Object.is({}, {})` 为 `false`。 |
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.
在React中开发者中通常习惯于对象的“浅比较”,这里我还是觉得“浅层相等”比较合适,也符合字面意思
Co-authored-by: Yucohny <79147654+Yucohny@users.noreply.github.com>
@awxiaoxian2020 @Yucohny @fwqaaq
翻译memo
幸苦review