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

Function validateFragmentProps

code/new-context-api/public/app.js:18923–18940  ·  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

18921 * @param {ReactElement} fragment
18922 */
18923function validateFragmentProps(fragment) {
18924 currentlyValidatingElement = fragment;
18925
18926 var keys = Object.keys(fragment.props);
18927 for (var i = 0; i < keys.length; i++) {
18928 var key = keys[i];
18929 if (!VALID_FRAGMENT_PROPS.has(key)) {
18930 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
18931 break;
18932 }
18933 }
18934
18935 if (fragment.ref !== null) {
18936 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
18937 }
18938
18939 currentlyValidatingElement = null;
18940}
18941
18942function createElementWithValidation(type, props, children) {
18943 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected