1 |
|
2 | 'use strict'
|
3 | const React = require('react')
|
4 | const formatChildren = require('./base-format-children')
|
5 |
|
6 | function applyChildren (key/*: string */, element/*: any */, children/*: ?mixed[] */) {
|
7 | if (process.env.NODE_ENV !== 'production' && !React.isValidElement(element)) {
|
8 | throw new Error(JSON.stringify(element) + ' is not a valid element')
|
9 | }
|
10 |
|
11 |
|
12 | return React.cloneElement.apply(
|
13 | React,
|
14 | [ element, { key: element.key || key } ].concat(children || [])
|
15 | )
|
16 | }
|
17 |
|
18 | exports.formatChildren = formatChildren.bind(null, applyChildren)
|