* Maps children that are typically specified as `props.children`. * * See https://reactjs.org/docs/react-api.html#reactchildrenmap * * The provided mapFunction(child, index) will be called for each * leaf child. * * @param {?*} children Children tree container. * @param {function(*, int)} fu
( children: ?ReactNodeList, func: MapFunc, context: mixed, )
| 355 | * @return {object} Object containing the ordered map of results. |
| 356 | */ |
| 357 | function mapChildren( |
| 358 | children: ?ReactNodeList, |
| 359 | func: MapFunc, |
| 360 | context: mixed, |
| 361 | ): ?Array<React$Node> { |
| 362 | if (children == null) { |
| 363 | // $FlowFixMe limitation refining abstract types in Flow |
| 364 | return children; |
| 365 | } |
| 366 | const result: Array<React$Node> = []; |
| 367 | let count = 0; |
| 368 | mapIntoArray(children, result, '', '', function (child) { |
| 369 | return func.call(context, child, count++); |
| 370 | }); |
| 371 | return result; |
| 372 | } |
| 373 | |
| 374 | /** |
| 375 | * Count the number of children that are typically specified as |
no test coverage detected