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

Function validateFragmentProps

code/third-party/public/app.js:18795–18812  ·  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

18793 * @param {ReactElement} fragment
18794 */
18795function validateFragmentProps(fragment) {
18796 currentlyValidatingElement = fragment;
18797
18798 var keys = Object.keys(fragment.props);
18799 for (var i = 0; i < keys.length; i++) {
18800 var key = keys[i];
18801 if (!VALID_FRAGMENT_PROPS.has(key)) {
18802 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
18803 break;
18804 }
18805 }
18806
18807 if (fragment.ref !== null) {
18808 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
18809 }
18810
18811 currentlyValidatingElement = null;
18812}
18813
18814function createElementWithValidation(type, props, children) {
18815 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected