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/memo into Chinese #1160

Merged
merged 11 commits into from
Jun 20, 2023

Conversation

BetterZxx
Copy link
Contributor

@awxiaoxian2020 @Yucohny @fwqaaq
翻译memo
幸苦review

@github-actions
Copy link

github-actions bot commented May 9, 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/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved

</DeepDive>

---

### Updating a memoized component using state {/*updating-a-memoized-component-using-state*/}
### 使用 state 更新 memoized(记忆化)组件 {/*updating-a-memoized-component-using-state*/}
Copy link
Collaborator

Choose a reason for hiding this comment

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

前文是使用的“记忆化(memoized)”,这里是使用的的“memoized(记忆化)”,这种地方需要统一一下,建议使用“记忆化(memoized)”,用 memoized 解释“记忆化”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

嗯,这里我统一一下


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

Choose a reason for hiding this comment

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

“浅层相等”意思没有什么问题,也容易理解,但是“非严格相等”会不会更加合适一点?(因为考虑到通常会说“严格相等”。)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

在React中开发者中通常习惯于对象的“浅比较”,这里我还是觉得“浅层相等”比较合适,也符合字面意思

src/content/reference/react/memo.md Outdated Show resolved Hide resolved
@Yucohny Yucohny added the Pending Modify 已校对,待修改阶段 label Jun 19, 2023
loveloki
loveloki previously approved these changes Jun 20, 2023
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
src/content/reference/react/memo.md Outdated Show resolved Hide resolved
@Yucohny Yucohny merged commit db52114 into reactjs:main Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Modify 已校对,待修改阶段
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants