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

Function validateFragmentProps

code/styling/public/app.js:19562–19579  ·  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

19560 * @param {ReactElement} fragment
19561 */
19562function validateFragmentProps(fragment) {
19563 currentlyValidatingElement = fragment;
19564
19565 var keys = Object.keys(fragment.props);
19566 for (var i = 0; i < keys.length; i++) {
19567 var key = keys[i];
19568 if (!VALID_FRAGMENT_PROPS.has(key)) {
19569 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
19570 break;
19571 }
19572 }
19573
19574 if (fragment.ref !== null) {
19575 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
19576 }
19577
19578 currentlyValidatingElement = null;
19579}
19580
19581function createElementWithValidation(type, props, children) {
19582 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected