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

Function validateFragmentProps

code/redux/public/app.js:20906–20923  ·  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

20904 * @param {ReactElement} fragment
20905 */
20906function validateFragmentProps(fragment) {
20907 currentlyValidatingElement = fragment;
20908
20909 var keys = Object.keys(fragment.props);
20910 for (var i = 0; i < keys.length; i++) {
20911 var key = keys[i];
20912 if (!VALID_FRAGMENT_PROPS.has(key)) {
20913 warning(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.%s', key, getStackAddendum());
20914 break;
20915 }
20916 }
20917
20918 if (fragment.ref !== null) {
20919 warning(false, 'Invalid attribute `ref` supplied to `React.Fragment`.%s', getStackAddendum());
20920 }
20921
20922 currentlyValidatingElement = null;
20923}
20924
20925function createElementWithValidation(type, props, children) {
20926 var validType = typeof type === 'string' || typeof type === 'function' ||

Callers 1

Calls 2

warningFunction · 0.85
getStackAddendumFunction · 0.70

Tested by

no test coverage detected