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 content/docs/reference-react-dom.md into Chinese #96

Merged
merged 7 commits into from
Mar 7, 2019

Conversation

Ryanhui
Copy link
Contributor

@Ryanhui Ryanhui commented Feb 13, 2019

No description provided.

@netlify
Copy link

netlify bot commented Feb 13, 2019

Deploy preview for cn-reactjs ready!

Built with commit 1c9948d

https://deploy-preview-96--cn-reactjs.netlify.com

@QC-L QC-L added the Pending Review 已翻译,待校对阶段 label Feb 13, 2019
@QC-L QC-L mentioned this pull request Feb 14, 2019
Copy link
Contributor

@yhsunshining yhsunshining left a comment

Choose a reason for hiding this comment

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

更新至 L55,
主要是与英文原文行对应关系的问题,另外一些小的细节麻烦看下~
thx.

@@ -6,71 +6,68 @@ category: Reference
permalink: docs/react-dom.html
---

If you load React from a `<script>` tag, these top-level APIs are available on the `ReactDOM` global. If you use ES6 with npm, you can write `import ReactDOM from 'react-dom'`. If you use ES5 with npm, you can write `var ReactDOM = require('react-dom')`.
如果你使用一个 `<script>` 标签引入React,所有的顶层API都能在 `ReactDOM` 的全局范围内被调用。如果你使用npm和ES6, 你可以用 `import ReactDOM from 'react-dom'`。如果你使用npm和ES5, 你可以用 `var ReactDOM = require('react-dom')`
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. ReactDOM global,感觉应该是指全局window下的 ReactDom 对象
  2. 少了一些空格~
Suggested change
如果你使用一个 `<script>` 标签引入React,所有的顶层API都能在 `ReactDOM` 的全局范围内被调用。如果你使用npm和ES6, 你可以用 `import ReactDOM from 'react-dom'`如果你使用npm和ES5, 你可以用 `var ReactDOM = require('react-dom')`
如果你使用一个 `<script>` 标签引入React,所有的顶层 API 都能在全局 `ReactDOM` 上被调用。如果你使用 npm 和 ES6,你可以用 `import ReactDOM from 'react-dom'`如果你使用 npm 和 ES5,你可以用 `var ReactDOM = require('react-dom')`


The `react-dom` package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to. Most of your components should not need to use this module.
`react-dom` 包提供了可在应用顶层使用的 DOM 特定(DOM-specific)的方法,如果有需要,你可以把这些方法用作到React模型外面的逃生出口。不过一般情况下,你的大部分组件都不需要使用这个包。
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. DOM-specific method 可以翻译成 针对 DOM 的方法
  2. module 如果直译的话,翻译成模块 是不是好一点。不过如果要和上文对照的话,上面用了package 包。
Suggested change
`react-dom` 包提供了可在应用顶层使用的 DOM 特定(DOM-specific)的方法,如果有需要,你可以把这些方法用作到React模型外面的逃生出口。不过一般情况下,你的大部分组件都不需要使用这个包
`react-dom` 包提供了可在应用顶层使用的针对 DOM (DOM-specific)的方法,如果有需要,你可以把这些方法用作到 React 模型外面的逃生出口。不过一般情况下,你的大部分组件都不需要使用这个模块


### `render()` {#render}

```javascript
ReactDOM.render(element, container[, callback])
```
在提供的 `container` 里渲染一个 React 元素,返回一个这个组件的[引用](/docs/more-about-refs.html)(或者为[无状态组件](/docs/components-and-props.html#functional-and-class-components)返回 `null`)。
Copy link
Contributor

Choose a reason for hiding this comment

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

原文38 是一个空行,建议保持一致

If the optional callback is provided, it will be executed after the component is rendered or updated.

> Note:
> 注意:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
> 注意:
> 注意

>
> `ReactDOM.render()` controls the contents of the container node you pass in. Any existing DOM elements inside are replaced when first called. Later calls use React’s DOM diffing algorithm for efficient updates.
> `ReactDOM.render()` 会控制你提供的容器节点里的内容。当第一次调用时,容器节点里的所有 DOM 元素都会被清除,后续的调用则会使用 React 的 DOM 差分算法(DOM diffing algorithm)进行高效的更新。
Copy link
Contributor

Choose a reason for hiding this comment

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

replaced 翻译为 替换?原 DOM 被替换为组件DOM

Suggested change
> `ReactDOM.render()` 会控制你提供的容器节点里的内容。当第一次调用时,容器节点里的所有 DOM 元素都会被清除,后续的调用则会使用 React 的 DOM 差分算法(DOM diffing algorithm)进行高效的更新。
> `ReactDOM.render()` 会控制你提供的容器节点里的内容。当第一次调用时,容器节点里的所有 DOM 元素都会被替换,后续的调用则会使用 React 的 DOM 差分算法(DOM diffing algorithm)进行高效的更新。

> `ReactDOM.render()` currently returns a reference to the root `ReactComponent` instance. However, using this return value is legacy
> and should be avoided because future versions of React may render components asynchronously in some cases. If you need a reference to the root `ReactComponent` instance, the preferred solution is to attach a
> [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) to the root element.
> `ReactDOM.render()` 目前会返回一个指向根 `ReactComponent` 实例的引用。但是使用返回值的这种写法来自历史遗留并且应该避免,因为在未来版本的 React 中,组件的渲染在某些情况下会是异步的。如果你真的需要一个指向根 `ReactComponent` 实例的引用,推荐的方法是添加一个 [callback ref](/docs/more-about-refs.html#the-ref-callback-attribute) 到根元素上。
Copy link
Contributor

Choose a reason for hiding this comment

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

legacy 在 issue 中看到好像建议翻为 废弃
另外行数要不要保持一致?

Copy link
Member

Choose a reason for hiding this comment

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

行数保持一致吧,可以拆成三句

>
> Using `ReactDOM.render()` to hydrate a server-rendered container is deprecated and will be removed in React 17. Use [`hydrate()`](#hydrate) instead.
> 使用 `ReactDOM.render()` 混合服务端渲染的容器已经弃用了,并且会在 React 17 被移除。作为替代,使用 [`hydrate()`](#hydrate)
Copy link
Contributor

Choose a reason for hiding this comment

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

hydrate(hydrate a server-rendered containe) 在群里讨论的结果 应该是保留不翻, 这个大家可以再看下此处要不要翻

@netlify
Copy link

netlify bot commented Feb 28, 2019

Deploy preview for zh-hans-reactjs ready!

Built with commit 1c9948d

https://deploy-preview-96--zh-hans-reactjs.netlify.com

@@ -20,11 +20,11 @@ permalink: docs/react-dom.html

### 浏览器支持 {#browser-support}

React 支持所有的现代浏览器,包括 IE9 及以上版本,但是需要为老浏览器比如 IE9 和 IE10 引入[一些polyfills](/docs/javascript-environment-requirements.html)。
React 支持所有的现代浏览器,包括 IE9 及以上版本,但是需要为老浏览器比如 IE9 和 IE10 引入[一些 polyfills](/docs/javascript-environment-requirements.html)
Copy link
Contributor

Choose a reason for hiding this comment

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

西文和全角标点之间不应该有空格


> 注意:
>
>我们不支持那些不兼容 ES5 方法的老浏览器,但如果你的应用包含了 polyfill,例如 [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) 你可能会发现你的应用仍然可以在这些浏览器中正常运行。不过如果你选择这种方法,你便需要孤军奋战了。
>我们不支持那些不兼容 ES5 方法的老浏览器,但如果你的应用包含了 polyfill ,例如 [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) 你可能会发现你的应用仍然可以在这些浏览器中正常运行。不过如果你选择这种方法,你便需要孤军奋战了。
Copy link
Contributor

Choose a reason for hiding this comment

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

这里也一样, folyfill 和 , 之间没有空格

Copy link
Contributor

@yhsunshining yhsunshining left a comment

Choose a reason for hiding this comment

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

建议整理下西文和全角标点的空格,提交 d8ab5c4 引入了一些格式的错误更改。


## Overview {#overview}
## 概述 {#overview}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
## 概述 {#overview}
## 概览 {#overview}

@@ -6,71 +6,69 @@ category: Reference
permalink: docs/react-dom.html
---

If you load React from a `<script>` tag, these top-level APIs are available on the `ReactDOM` global. If you use ES6 with npm, you can write `import ReactDOM from 'react-dom'`. If you use ES5 with npm, you can write `var ReactDOM = require('react-dom')`.
如果你使用一个 `<script>` 标签引入 React ,所有的顶层 API 都能在全局 `ReactDOM` 上调用。如果你使用 npm 和 ES6 ,你可以用 `import ReactDOM from 'react-dom'` 。如果你使用 npm 和 ES5 ,你可以用 `var ReactDOM = require('react-dom')`
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
如果你使用一个 `<script>` 标签引入 React ,所有的顶层 API 都能在全局 `ReactDOM` 上调用。如果你使用 npm 和 ES6 ,你可以用 `import ReactDOM from 'react-dom'` 。如果你使用 npm 和 ES5 ,你可以用 `var ReactDOM = require('react-dom')`
如果你使用一个 `<script>` 标签引入 React,所有的顶层 API 都能在全局 `ReactDOM` 上调用。如果你使用 npm 和 ES6 ,你可以用 `import ReactDOM from 'react-dom'`。如果你使用 npm 和 ES5,你可以用 `var ReactDOM = require('react-dom')`


The `react-dom` package provides DOM-specific methods that can be used at the top level of your app and as an escape hatch to get outside of the React model if you need to. Most of your components should not need to use this module.
`react-dom` 包提供了可在应用顶层使用的针对 DOM(DOM-specific)的方法,如果有需要,你可以把这些方法用作到 React 模型外面的逃生出口。不过一般情况下,你的大部分组件都不需要使用这个模块。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
`react-dom` 包提供了可在应用顶层使用的针对 DOM(DOM-specific)的方法,如果有需要,你可以把这些方法用作到 React 模型外面的逃生出口。不过一般情况下,你的大部分组件都不需要使用这个模块
`react-dom` 的 package 提供了可在应用顶层使用的 DOM(DOM-specific)方法,如果有需要,你可以把这些方法用于 React 模型以外的地方。不过一般情况下,大部分组件都不需要使用这个模块


React supports all popular browsers, including Internet Explorer 9 and above, although [some polyfills are required](/docs/javascript-environment-requirements.html) for older browsers such as IE 9 and IE 10.
React 支持所有的现代浏览器,包括 IE9 及以上版本,但是需要为老浏览器比如 IE9 和 IE10 引入[一些 polyfills](/docs/javascript-environment-requirements.html)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
React 支持所有的现代浏览器,包括 IE9 及以上版本,但是需要为老浏览器比如 IE9 和 IE10 引入[一些 polyfills](/docs/javascript-environment-requirements.html)
React 支持所有的现代浏览器,包括 IE9 及以上版本,但是需要为旧版浏览器比如 IE9 和 IE10 引入[相关的 polyfills 依赖](/docs/javascript-environment-requirements.html)

>
> We don't support older browsers that don't support ES5 methods, but you may find that your apps do work in older browsers if polyfills such as [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) are included in the page. You're on your own if you choose to take this path.
>我们不支持那些不兼容 ES5 方法的老浏览器,但如果你的应用包含了 polyfill ,例如 [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) 你可能会发现你的应用仍然可以在这些浏览器中正常运行。不过如果你选择这种方法,你便需要孤军奋战了。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
>我们不支持那些不兼容 ES5 方法的老浏览器,但如果你的应用包含了 polyfill ,例如 [es5-shim and es5-sham](https://github.com/es-shims/es5-shim) 你可能会发现你的应用仍然可以在这些浏览器中正常运行。不过如果你选择这种方法,你便需要孤军奋战了。
>我们不支持那些不兼容 ES5 方法的旧版浏览器,但如果你的应用包含了 polyfill,例如 [es5-shim es5-sham](https://github.com/es-shims/es5-shim) 你可能会发现你的应用仍然可以在这些浏览器中正常运行。但是如果你选择这种方法,你便需要孤军奋战了。


```javascript
ReactDOM.findDOMNode(component)
```
If this component has been mounted into the DOM, this returns the corresponding native browser DOM element. This method is useful for reading values out of the DOM, such as form field values and performing DOM measurements. **In most cases, you can attach a ref to the DOM node and avoid using `findDOMNode` at all.**
如果组件已经被挂载到 DOM 上,这个方法会返回相应的原生浏览器 DOM 元素。这个方法对于从 DOM 中读取值很有用,例如表单字段的值和执行 DOM 测量(performing DOM measurements)。**大多数情况下,你可以绑定一个 ref DOM 节点上,完全避免使用 findDOMNode**
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
如果组件已经被挂载到 DOM 上,这个方法会返回相应的原生浏览器 DOM 元素。这个方法对于从 DOM 中读取值很有用,例如表单字段的值和执行 DOM 测量(performing DOM measurements)。**大多数情况下,你可以绑定一个 ref 到 DOM 节点上,完全避免使用 findDOMNode。**
如果组件已经被挂载到 DOM 上,此方法会返回浏览器中相应的原生 DOM 元素。此方法对于从 DOM 中读取值很有用,例如获取表单字段的值或者执行 DOM 检测(performing DOM measurements)。**大多数情况下,你可以绑定一个 ref 到 DOM 节点上,可以完全避免使用 findDOMNode。**


When a component renders to `null` or `false`, `findDOMNode` returns `null`. When a component renders to a string, `findDOMNode` returns a text DOM node containing that value. As of React 16, a component may return a fragment with multiple children, in which case `findDOMNode` will return the DOM node corresponding to the first non-empty child.
当一个组件渲染的内容是 `null` 或者 `false` 时, `findDOMNode` 返回的是 `null` 。当一个组件渲染的是字符串时,`findDOMNode` 返回的包含这个值的文本 DOM 节点。从 React 16 开始,一个组件可能会返回有多个子节点的碎片(fragment),在这个情况下,`findDOMNode` 会返回第一个非空子节点对应的 DOM 节点。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
当一个组件渲染的内容是 `null` 或者 `false` 时, `findDOMNode` 返回的是 `null` 。当一个组件渲染的是字符串时`findDOMNode` 返回的包含这个值的文本 DOM 节点。从 React 16 开始,一个组件可能会返回有多个子节点的碎片(fragment),在这个情况下`findDOMNode` 会返回第一个非空子节点对应的 DOM 节点。
当组件渲染的内容为 `null` `false` 时,`findDOMNode` 也会返回 `null`。当组件渲染的是字符串时`findDOMNode` 返回的是字符串对应的 DOM 节点。从 React 16 开始,组件可能会返回有多个子节点的 fragment,在这种情况下`findDOMNode` 会返回第一个非空子节点对应的 DOM 节点。

>
> `findDOMNode` cannot be used on function components.
> `findDOMNode` 只在挂载的组件上可用(即,已经放置在 DOM 中的组件)。如果你尝试调用一个未挂载的组件(例如在一个还未创建的组件上调用 `render()` 中的 `findDOMNode()`)将会引发异常。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> `findDOMNode` 只在挂载的组件上可用(即,已经放置在 DOM 中的组件)。如果你尝试调用一个未挂载的组件(例如在一个还未创建的组件上调用 `render()` 中的 `findDOMNode()`)将会引发异常。
> `findDOMNode` 只在已挂载的组件上可用(即,已经放置在 DOM 中的组件)。如果你尝试调用未挂载的组件(例如在一个还未创建的组件上调用 `render()` 中的 `findDOMNode()`)将会引发异常。

> `findDOMNode` cannot be used on function components.
> `findDOMNode` 只在挂载的组件上可用(即,已经放置在 DOM 中的组件)。如果你尝试调用一个未挂载的组件(例如在一个还未创建的组件上调用 `render()` 中的 `findDOMNode()`)将会引发异常。
>
> `findDOMNode` 不能用于函数式组件。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> `findDOMNode` 不能用于函数式组件
> `findDOMNode` 不能用于函数组件

@@ -110,5 +107,4 @@ When a component renders to `null` or `false`, `findDOMNode` returns `null`. Whe
```javascript
ReactDOM.createPortal(child, container)
```

Creates a portal. Portals provide a way to [render children into a DOM node that exists outside the hierarchy of the DOM component](/docs/portals.html).
创建一个入口。入口提供了一种[将子节点渲染到 DOM 节点中的方法,该节点存在于 DOM 组件的层次结构之外](/docs/portals.html)。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
创建一个入口。入口提供了一种[将子节点渲染到 DOM 节点中的方法,该节点存在于 DOM 组件的层次结构之外](/docs/portals.html)
创建 portal。[Portal](/docs/portals.html) 将提供一种将子节点渲染到 DOM 节点中的方式,该节点存在于 DOM 组件的层次结构之外。

@QC-L QC-L added Pending Modify 已校对,待修改阶段 and removed Pending Review 已翻译,待校对阶段 labels Mar 6, 2019
@QC-L QC-L added Pending Re-Review 已修改,待审校阶段 and removed Pending Modify 已校对,待修改阶段 labels Mar 7, 2019
@hijiangtao hijiangtao merged commit 6a40587 into reactjs:master Mar 7, 2019
OhIAmFine pushed a commit to OhIAmFine/zh-hans.reactjs.org that referenced this pull request May 6, 2019
…eactjs#96)

* docs(cn): translate content/docs/reference-react-dom.md into Chinese

* change 您 to 你

* modify

* modify

* Update reference-react-dom.md

* Update reference-react-dom.md

* Update reference-react-dom.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pending Re-Review 已修改,待审校阶段
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants