MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / validateFragmentProps

Function validateFragmentProps

code/communication/public/app.js:19597–19614  ·  view source on GitHub ↗

* Given a fragment, validate that it can only be provided with fragment props * @param {ReactElement} fragment

(fragment)

Source from the content-addressed store, hash-verified

19595 * @param {ReactElement} fragment
19596 */
19597function validateFragmentProps(fragment) {
19598 currentlyValidatingElement = fragment;
19599
19600 var keys = Object.keys(fragment.props);
19601 for (var i = 0; i < keys.length; i++) {
19602 var key = keys[i];
19603 if (!VALID_FRAGMENT_PROPS.has(key)) {
19604 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
19605 break;
19606 }
19607 }
19608
19609 if (fragment.ref !== null) {
19610 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
19611 }
19612
19613 currentlyValidatingElement = null;
19614}
19615
19616function createElementWithValidation(type, props, children) {
19617 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected