MCPcopy Create free account
hub / github.com/reactjs/react-rails / onlyChild

Function onlyChild

lib/assets/react-source/development/react.js:1640–1648  ·  view source on GitHub ↗

* 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 wrapp

(children)

Source from the content-addressed store, hash-verified

1638
1639
1640 function onlyChild(children) {
1641 if (!isValidElement(children)) {
1642 {
1643 throw Error( "React.Children.only expected to receive a single React element child." );
1644 }
1645 }
1646
1647 return children;
1648 }
1649
1650 function createContext(defaultValue, calculateChangedBits) {
1651 if (calculateChangedBits === undefined) {

Callers

nothing calls this directly

Calls 1

isValidElementFunction · 0.70

Tested by

no test coverage detected