* Returns the first child in a collection of children and verifies that there * is only one child in the collection. * * See https://reactjs.org/docs/react-api.html#reactchildrenonly * * The current implementation of this function assumes that a single child gets * passed without a wrapper, bu
(children: T)
| 444 | * structure. |
| 445 | */ |
| 446 | function onlyChild<T>(children: T): T { |
| 447 | if (!isValidElement(children)) { |
| 448 | throw new Error( |
| 449 | 'React.Children.only expected to receive a single React element child.', |
| 450 | ); |
| 451 | } |
| 452 | |
| 453 | return children; |
| 454 | } |
| 455 | |
| 456 | export { |
| 457 | forEachChildren as forEach, |
nothing calls this directly
no test coverage detected