MCPcopy Create free account
hub / github.com/microsoft/SandDance / onlyChild

Function onlyChild

docs/external/js/react.development.js:1334–1342  ·  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

(children)

Source from the content-addressed store, hash-verified

1332
1333
1334 function onlyChild(children) {
1335 if (!isValidElement(children)) {
1336 {
1337 throw Error( "React.Children.only expected to receive a single React element child." );
1338 }
1339 }
1340
1341 return children;
1342 }
1343
1344 function createContext(defaultValue, calculateChangedBits) {
1345 if (calculateChangedBits === undefined) {

Callers

nothing calls this directly

Calls 1

isValidElementFunction · 0.85

Tested by

no test coverage detected