Skip to content

Commit c0660ea

Browse files
committed
Merge pull request #1100 from plievone/mapchildren-docs
Fix docs for React.Children.map, .forEach, .only.
2 parents cb1f824 + 827c44f commit c0660ea

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

docs/docs/ref-01-top-level-api.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,26 @@ next: component-api.html
1818
#### React.Children.map
1919

2020
```javascript
21-
array React.Children.map(object children, function fn [, object context])
21+
object React.Children.map(object children, function fn [, object context])
2222
```
2323

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.
2525

2626
#### React.Children.forEach
2727

2828
```javascript
2929
React.Children.forEach(object children, function fn [, object context])
3030
```
3131

32-
Like `React.Children.map()` but does not return an array.
32+
Like `React.Children.map()` but does not return an object.
3333

34-
#### React.children.only()
34+
#### React.Children.only
3535

3636
```javascript
3737
object React.Children.only(object children)
3838
```
3939

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.
4141

4242

4343
### React.DOM

src/utils/ReactChildren.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function forEachSingleChild(traverseContext, child, name, i) {
5252
* The provided forEachFunc(child, index) will be called for each
5353
* leaf child.
5454
*
55-
* @param {array} children
55+
* @param {?*} children Children tree container.
5656
* @param {function(*, int)} forEachFunc.
5757
* @param {*} forEachContext Context for forEachContext.
5858
*/
@@ -107,10 +107,10 @@ function mapSingleChildIntoContext(traverseContext, child, name, i) {
107107
* TODO: This may likely break any calls to `ReactChildren.map` that were
108108
* previously relying on the fact that we guarded against null children.
109109
*
110-
* @param {array} children
110+
* @param {?*} children Children tree container.
111111
* @param {function(*, int)} mapFunction.
112112
* @param {*} mapContext Context for mapFunction.
113-
* @return {array} mirrored array with mapped children.
113+
* @return {object} Object containing the ordered map of results.
114114
*/
115115
function mapChildren(children, func, context) {
116116
if (children == null) {

0 commit comments

Comments
 (0)