Fix docs for React.Children.map, .forEach, .only.
plievone committed
Feb 16, 2014 at 22:27 UTC
827c44fcd332443d8ac615d7f70895c6edda1b10
2 files changed
+8
-8
docs/docs/ref-01-top-level-api.md
+5
-5
@@ -18,10 +18,10 @@ next: component-api.html
18
#### React.Children.map
19
20
```javascript
21
-array React.Children.map(object children, function fn [, object context])
21
+object React.Children.map(object children, function fn [, object context])
22
```
23
24
-Invoke `fn` on every immediate child contained within `children` with `this` set to `context`. If `children` is a nested object or array it will be traversed: `fn` will never be passed the container objects.
24
+Invoke `fn` on every immediate child contained within `children` with `this` set to `context`. If `children` is a nested object or array it will be traversed: `fn` will never be passed the container objects. If children is `null` or `undefined` returns `null` or `undefined` rather than an empty object.
25
26
#### React.Children.forEach
27
@@ -29,15 +29,15 @@ Invoke `fn` on every immediate child contained within `children` with `this` set
29
React.Children.forEach(object children, function fn [, object context])
30
```
31
32
-Like `React.Children.map()` but does not return an array.
32
+Like `React.Children.map()` but does not return an object.
33
34
-#### React.children.only()
34
+#### React.Children.only
35
36
```javascript
37
object React.Children.only(object children)
38
```
39
40
-Return the only child in `children`. If `children` is a nested object or array it will be traversed.
40
+Return the only child in `children`. Throws otherwise.
41
42
43
### React.DOM
src/utils/ReactChildren.js
+3
-3
@@ -52,7 +52,7 @@ function forEachSingleChild(traverseContext, child, name, i) {
52
* The provided forEachFunc(child, index) will be called for each
53
* leaf child.
54
*
55
- * @param {array} children
55
+ * @param {?*} children Children tree container.
56
* @param {function(*, int)} forEachFunc.
57
* @param {*} forEachContext Context for forEachContext.
58
*/
@@ -107,10 +107,10 @@ function mapSingleChildIntoContext(traverseContext, child, name, i) {
107
* TODO: This may likely break any calls to `ReactChildren.map` that were
108
* previously relying on the fact that we guarded against null children.
109
*
110
- * @param {array} children
110
+ * @param {?*} children Children tree container.
111
* @param {function(*, int)} mapFunction.
112
* @param {*} mapContext Context for mapFunction.
113
- * @return {array} mirrored array with mapped children.
113
+ * @return {object} Object containing the ordered map of results.
114
*/
115
function mapChildren(children, func, context) {
116
if (children == null) {