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

Function validateFragmentProps

code/composition/public/app.js:19700–19717  ·  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

19698 * @param {ReactElement} fragment
19699 */
19700function validateFragmentProps(fragment) {
19701 currentlyValidatingElement = fragment;
19702
19703 var keys = Object.keys(fragment.props);
19704 for (var i = 0; i < keys.length; i++) {
19705 var key = keys[i];
19706 if (!VALID_FRAGMENT_PROPS.has(key)) {
19707 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
19708 break;
19709 }
19710 }
19711
19712 if (fragment.ref !== null) {
19713 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
19714 }
19715
19716 currentlyValidatingElement = null;
19717}
19718
19719function createElementWithValidation(type, props, children) {
19720 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected