Skip to content

Update reference-react-component.md #691

New issue

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

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

Already on GitHub? # to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

zaoren
Copy link

@zaoren zaoren commented Dec 10, 2021

There are some small mistakes that can mislead others
reference facebook/react#9117

@@ -194,7 +194,7 @@ constructor(props) {
componentDidMount()
```

`componentDidMount()` 会在组件挂载后(插入 DOM 树中)立即调用。依赖于 DOM 节点的初始化应该放在这里。如需通过网络请求获取数据,此处是实例化请求的好地方。
`componentDidMount()` 会在组件挂载后(在他自己的容器中挂载完成了,并不代表已经挂载到DOM树)立即调用。依赖于 DOM 节点的初始化应该放在这里。如需通过网络请求获取数据,此处是实例化请求的好地方。
Copy link
Contributor

@KimYangOfCat KimYangOfCat Dec 31, 2021

Choose a reason for hiding this comment

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

@zaoren Hello,我查阅了本段的英文:

componentDidMount() is invoked immediately after a component is mounted (inserted into the tree). Initialization that requires DOM nodes should go here. If you need to load data from a remote endpoint, this is a good place to instantiate the network request.

这里括号里面的内容应该是用于解释 mounted 这个动词哒,意思就是说挂载这个动作与”插入DOM树中“一样;所以这里应该不是想表达”已经挂载到 DOM 树中“的这个观点。所以严格意义上来说,中英文表达的意思是一样的,如果你对英文原文有异议,可以考虑到英文文档中提交 issue讨论。

也许是这个括号的位置不太对,导致了你的误解,可以考虑调整如下:

Suggested change
`componentDidMount()` 会在组件挂载后(在他自己的容器中挂载完成了,并不代表已经挂载到DOM树)立即调用。依赖于 DOM 节点的初始化应该放在这里。如需通过网络请求获取数据,此处是实例化请求的好地方。
`componentDidMount()` 会在组件挂载(插入 DOM 树中)后立即调用。依赖于 DOM 节点的初始化应该放在这里。如需通过网络请求获取数据,此处是实例化请求的好地方。

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
Author

Choose a reason for hiding this comment

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

好的 感谢大佬回复... 才看到邮件😂

@QC-L QC-L closed this Feb 7, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants