`,任何的调整都会导致全部重建。
-When tearing down a tree, old DOM nodes are destroyed. Component instances receive `componentWillUnmount()`. When building up a new tree, new DOM nodes are inserted into the DOM. Component instances receive `componentWillMount()` and then `componentDidMount()`. Any state associated with the old tree is lost.
+当树被卸载,旧的DOM节点将被销毁。组件实例将会接收到`componentWillUnmount()`方法。当构建一棵新树,新的DOM节点被插入到DOM中。组件实例将接收到`componentWillMount()`以及之后的`componentDidMount()`。任何有关旧树的状态都将被丢弃。
-Any components below the root will also get unmounted and have their state destroyed. For example, when diffing:
+下面任何组件的根节点将会被卸载同时他们的状态将销毁。例如,在进行对比:
```xml
@@ -41,11 +41,11 @@ Any components below the root will also get unmounted and have their state destr
```
-This will destroy the old `Counter` and remount a new one.
+这将会销毁旧的`Counter`并重装新节点。
-### DOM Elements Of The Same Type
+### 相同类型的DOM元素
-When comparing two React DOM elements of the same type, React looks at the attributes of both, keeps the same underlying DOM node, and only updates the changed attributes. For example:
+当比较两个相同类型的React DOM元素时,React则会观察二者的属性,保持相同的底层DOM节点,并仅更新变化的属性。例如:
```xml
@@ -53,9 +53,9 @@ When comparing two React DOM elements of the same type, React looks at the attri
```
-By comparing these two elements, React knows to only modify the `className` on the underlying DOM node.
+通过比较两个元素,React知道仅更改底层DOM元素的`className`。
-When updating `style`, React also knows to update only the properties that changed. For example:
+当更新`style`时,React同样知道仅更新变更的属性。例如:
```xml
@@ -63,21 +63,21 @@ When updating `style`, React also knows to update only the properties that chang
```
-When converting between these two elements, React knows to only modify the `color` style, not the `fontWeight`.
+当在调整两个元素时,React知道仅改变`color`样式而不是`fontWeight`。
-After handling the DOM node, React then recurses on the children.
+在处理完DOM元素后,React递归其子元素。
-### Component Elements Of The Same Type
+### 相同类型的组件元素
-When a component updates, the instance stays the same, so that state is maintained across renders. React updates the props of the underlying component instance to match the new element, and calls `componentWillReceiveProps()` and `componentWillUpdate()` on the underlying instance.
+当组件更新时,实例仍保持一致,以让状态能够在渲染之间保留。React更新底层组件实例的属性以满足新元素,并在底层实例上调用`componentWillReceiveProps()` 和 `componentWillUpdate()` 方法。
-Next, the `render()` method is called and the diff algorithm recurses on the previous result and the new result.
+接下来,`render()`方法被调用,同时对比算法会递归处理之前的结果和新的结果。
-### Recursing On Children
+### 递归子节点
-By default, when recursing on the children of a DOM node, React just iterates over both lists of children at the same time and generates a mutation whenever there's a difference.
+默认时。当递归DOM节点的子节点,React仅在同一时间点递归两个子节点列表,并在有不同时产生一个变更。
-For example, when adding an element at the end of the children, converting between these two trees works well:
+例如,当在子节点末尾增加一个元素,两棵树的转换效果很好:
```xml
@@ -92,9 +92,9 @@ For example, when adding an element at the end of the children, converting betwe
```
-React will match the two `
first` trees, match the two `
second` trees, and then insert the `
third` tree.
+React将会匹配两棵树的`
first`,并匹配两棵树的`
second` 节点,并插入`
third`节点树。
-If you implement it naively, inserting an element at the beginning has worse performance. For example, converting between these two trees works poorly:
+若原生实现,在开始插入元素会使得性能更棘手。例如,两棵树的转换效果则比较糟糕:
```xml
@@ -109,11 +109,11 @@ If you implement it naively, inserting an element at the beginning has worse per
```
-React will mutate every child instead of realizing it can keep the `
Duke` and `
Villanova` subtrees intact. This inefficiency can be a problem.
+React会调整每个子节点,而非意识到可以完整保留`
Duke` 和 `
Villanova`子树。低效成了一个问题。
### Keys
-In order to solve this issue, React supports a `key` attribute. When children have keys, React uses the key to match children in the original tree with children in the subsequent tree. For example, adding a `key` to our inefficient example above can make the tree conversion efficient:
+为解决该问题,React支持了一个`key`属性。当子节点有key时,React使用key来匹配原本树的子节点和新树的子节点。例如,增加一个`key`在之前效率不高的样例中能让树的转换变得高效:
```xml
@@ -128,26 +128,26 @@ In order to solve this issue, React supports a `key` attribute. When children ha
```
-Now React knows that the element with key `'2014'` is the new one, and the elements with the keys `'2015'` and `'2016'` have just moved.
+现在React知道带有`'2014'`的key的元素是新的,并仅移动带有`'2015'`和`'2016'`的key的元素。
-In practice, finding a key is usually not hard. The element you are going to display may already have a unique ID, so the key can just come from your data:
+实践中,发现key通常不难。你将展示的元素可能已经带有一个唯一的ID,因此key可以来自于你的数据中:
```js
{item.name}
```
-When that's not the case, you can add a new ID property to your model or hash some parts of the content to generate a key. The key only has to be unique among its siblings, not globally unique.
+当这已不再是问题,你可以增加一个新的ID属性到数据层或内容的部分哈希值以生成key。key必须在其兄弟节点中是唯一的,而非全局唯一。
-As a last resort, you can pass item's index in the array as a key. This can work well if the items are never reordered, but reorders will be slow.
+万不得已,你可以传递他们在数组中的索引作为key。若元素没有重排,该方法效果不错,但重排会使得其变慢。
-## Tradeoffs
+## 权衡
-It is important to remember that the reconciliation algorithm is an implementation detail. React could rerender the whole app on every action; the end result would be the same. We are regularly refining the heuristics in order to make common use cases faster.
+牢记协调算法的实现细节非常中。React可能会在每次操作时渲染整个应用;而结果仍是相同的。为保证大多数场景效率能更快,我们通常提炼启发式的算法。
-In the current implementation, you can express the fact that a subtree has been moved amongst its siblings, but you cannot tell that it has moved somewhere else. The algorithm will rerender that full subtree.
+在目前实现中,可以表明一个事实,即子树在其兄弟节点中移动,但你无法告知其移动到哪。该算法会重渲整个子树。
-Because React relies on heuristics, if the assumptions behind them are not met, performance will suffer.
+由于React依赖于该启发式算法,若其背后的假设没得到满足,则其性能将会受到影响:
-1. The algorithm will not try to match subtrees of different component types. If you see yourself alternating between two component types with very similar output, you may want to make it the same type. In practice, we haven't found this to be an issue.
+1. 算法无法尝试匹配不同组件类型的子元素。若你发现两个输出非常相似的组件类型交替出现,你可能希望使其成为相同类型。实践中,我们并非发现这是一个问题。
-2. Keys should be stable, predictable, and unique. Unstable keys (like those produced by `Math.random()`) will cause many component instances and DOM nodes to be unnecessarily recreated, which can cause performance degradation and lost state in child components.
+2. Keys应该是稳定的,可预测的,且唯一的。不稳定的key(类似由`Math.random()`生成的)将使得大量组件实例和DOM节点进行不必要的重建,使得性能下降并丢失子组件的状态。
diff --git a/docs/docs/reference-events.md b/docs/docs/reference-events.md
index 6e275db9b5..bd66cd13cc 100755
--- a/docs/docs/reference-events.md
+++ b/docs/docs/reference-events.md
@@ -5,14 +5,12 @@ permalink: docs/events.html
layout: docs
category: Reference
---
+此参考指南记录了构成React一部分事件系统的`SyntheticEvent`封装器。请参阅[事件处理](/react/docs/handling-events.html)指南了解更多。
-This reference guide documents the `SyntheticEvent` wrapper that forms part of React's Event System. See the [Handling Events](/react/docs/handling-events.html) guide to learn more.
+## 概述
+您的事件处理函数将会接收`SyntheticEvent`的实例,一个基于浏览器原生事件的跨浏览器实现。它拥有和浏览器原生事件一样的接口,包括`stopPropagation()`和`preventDefault()`,除了那些所有浏览器功能一样的事件。
-## Overview
-
-Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
-
-If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it. Every `SyntheticEvent` object has the following attributes:
+出于某些原因,你得使用一些底层的浏览器事件,只需用`nativeEnvent`的属性就能找到。每个`SyntheicEvent`对象都有如下属性:
```javascript
boolean bubbles
@@ -31,15 +29,13 @@ number timeStamp
string type
```
-> Note:
->
-> As of v0.14, returning `false` from an event handler will no longer stop event propagation. Instead, `e.stopPropagation()` or `e.preventDefault()` should be triggered manually, as appropriate.
+> 敲黑板:
+> 由于在v0.14版本中,事件处理函数返回`false`不会再阻止事件传播, 所以必须得手动触发`e.stopPropagation()`和`e.preventDefault()` 方法。
-### Event Pooling
+### 事件池
-The `SyntheticEvent` is pooled. This means that the `SyntheticEvent` object will be reused and all properties will be nullified after the event callback has been invoked.
-This is for performance reasons.
-As such, you cannot access the event in an asynchronous way.
+`SyntheticEvent`是共享的。那就意味着在调用事件回调之后,`SyntheticEvent`对象将会被重用,并且所有属性会被置空。这是出于性能因素考虑的。
+因此,您无法以异步方式访问事件。
```javascript
function onClick(event) {
@@ -60,15 +56,15 @@ function onClick(event) {
}
```
-> Note:
->
-> If you want to access the event properties in an asynchronous way, you should call `event.persist()` on the event, which will remove the synthetic event from the pool and allow references to the event to be retained by user code.
+> 敲黑板:
+>
+> 如果您想以异步的方式访问事件的属性值,你必须在事件回调中调用`event.persist()`方法,这样会在池中删除合成事件,并且在用户代码中保留对事件的引用。
-## Supported Events
+## 支持的事件
-React normalizes events so that they have consistent properties across different browsers.
+React标准化了事件,使其在不同的浏览器中拥有一致的属性。
-The event handlers below are triggered by an event in the bubbling phase. To register an event handler for the capture phase, append `Capture` to the event name; for example, instead of using `onClick`, you would use `onClickCapture` to handle the click event in the capture phase.
+下面的事件处理函数由冒泡阶段的事件触发。在事件名后面加`Capture`就能在事件捕获阶段注册事件处理函数。举个例子,你可以使用`onClickCapture`代替`onClick`在事件捕获阶段来处理点击事件。
- [Clipboard Events](#clipboard-events)
- [Composition Events](#composition-events)
@@ -85,19 +81,18 @@ The event handlers below are triggered by an event in the bubbling phase. To reg
- [Animation Events](#animation-events)
- [Transition Events](#transition-events)
-* * *
-
-## Reference
+***
+## 参考
### Clipboard Events
-Event names:
+事件名:
```
onCopy onCut onPaste
```
-Properties:
+属性:
```javascript
DOMDataTransfer clipboardData
@@ -107,13 +102,13 @@ DOMDataTransfer clipboardData
### Composition Events
-Event names:
+事件名:
```
onCompositionEnd onCompositionStart onCompositionUpdate
```
-Properties:
+属性:
```javascript
string data
@@ -124,13 +119,13 @@ string data
### Keyboard Events
-Event names:
+事件名:
```
onKeyDown onKeyPress onKeyUp
```
-Properties:
+属性:
```javascript
boolean altKey
@@ -151,15 +146,15 @@ number which
### Focus Events
-Event names:
+事件名:
```
onFocus onBlur
```
-These focus events work on all elements in the React DOM, not just form elements.
+这些焦点事件适用于React DOM中的所有元素,而不仅仅是表单元素。
-Properties:
+属性:
```javascript
DOMEventTarget relatedTarget
@@ -169,19 +164,19 @@ DOMEventTarget relatedTarget
### Form Events
-Event names:
+事件名:
```
onChange onInput onSubmit
```
-For more information about the onChange event, see [Forms](/react/docs/forms.html).
+查阅[表单](/react/docs/forms.html)了解关于onChange事件的更多细节.
* * *
### Mouse Events
-Event names:
+事件名:
```
onClick onContextMenu onDoubleClick onDrag onDragEnd onDragEnter onDragExit
@@ -189,9 +184,9 @@ onDragLeave onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
onMouseMove onMouseOut onMouseOver onMouseUp
```
-The `onMouseEnter` and `onMouseLeave` events propagate from the element being left to the one being entered instead of ordinary bubbling and do not have a capture phase.
+ `onMouseEnter` 和 `onMouseLeave` 事件由失去焦点的元素到正在输入的元素传播,并不是普通的冒泡,也没有捕获阶段。
-Properties:
+属性:
```javascript
boolean altKey
@@ -214,7 +209,7 @@ boolean shiftKey
### Selection Events
-Event names:
+事件名:
```
onSelect
@@ -224,13 +219,13 @@ onSelect
### Touch Events
-Event names:
+事件名:
```
onTouchCancel onTouchEnd onTouchMove onTouchStart
```
-Properties:
+属性:
```javascript
boolean altKey
@@ -247,13 +242,13 @@ DOMTouchList touches
### UI Events
-Event names:
+事件名:
```
onScroll
```
-Properties:
+属性:
```javascript
number detail
@@ -264,13 +259,13 @@ DOMAbstractView view
### Wheel Events
-Event names:
+事件名:
```
onWheel
```
-Properties:
+属性:
```javascript
number deltaMode
@@ -283,7 +278,7 @@ number deltaZ
### Media Events
-Event names:
+事件名:
```
onAbort onCanPlay onCanPlayThrough onDurationChange onEmptied onEncrypted
@@ -296,7 +291,7 @@ onTimeUpdate onVolumeChange onWaiting
### Image Events
-Event names:
+事件名:
```
onLoad onError
@@ -306,13 +301,13 @@ onLoad onError
### Animation Events
-Event names:
+事件名:
```
onAnimationStart onAnimationEnd onAnimationIteration
```
-Properties:
+属性:
```javascript
string animationName
@@ -324,13 +319,13 @@ float elapsedTime
### Transition Events
-Event names:
+事件名:
```
onTransitionEnd
```
-Properties:
+属性:
```javascript
string propertyName
diff --git a/docs/docs/reference-react-dom-server.md b/docs/docs/reference-react-dom-server.md
index 00bc87ba37..e5c9bb7c82 100755
--- a/docs/docs/reference-react-dom-server.md
+++ b/docs/docs/reference-react-dom-server.md
@@ -6,11 +6,11 @@ category: Reference
permalink: docs/react-dom-server.html
---
-If you load React from a `