MCPcopy Index your code
hub / github.com/plotly/dash / createElementWithValidation

Function createElementWithValidation

dash/deps/react@18.2.0.js:2311–2373  ·  view source on GitHub ↗
(type, props, children)

Source from the content-addressed store, hash-verified

2309 }
2310 }
2311 function createElementWithValidation(type, props, children) {
2312 var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
2313 // succeed and there will likely be errors in render.
2314
2315 if (!validType) {
2316 var info = '';
2317
2318 if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
2319 info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
2320 }
2321
2322 var sourceInfo = getSourceInfoErrorAddendumForProps(props);
2323
2324 if (sourceInfo) {
2325 info += sourceInfo;
2326 } else {
2327 info += getDeclarationErrorAddendum();
2328 }
2329
2330 var typeString;
2331
2332 if (type === null) {
2333 typeString = 'null';
2334 } else if (isArray(type)) {
2335 typeString = 'array';
2336 } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2337 typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
2338 info = ' Did you accidentally export a JSX literal instead of a component?';
2339 } else {
2340 typeString = typeof type;
2341 }
2342
2343 {
2344 error('React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
2345 }
2346 }
2347
2348 var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
2349 // TODO: Drop this when these are no longer allowed as the type argument.
2350
2351 if (element == null) {
2352 return element;
2353 } // Skip key warning if the type isn't valid since our key validation logic
2354 // doesn't expect a non-string/function type and can throw confusing errors.
2355 // We don't want exception behavior to differ between dev and prod.
2356 // (Rendering will throw with a helpful message and as soon as the type is
2357 // fixed, the key warnings will appear.)
2358
2359
2360 if (validType) {
2361 for (var i = 2; i < arguments.length; i++) {
2362 validateChildKeys(arguments[i], type);
2363 }
2364 }
2365
2366 if (type === REACT_FRAGMENT_TYPE) {
2367 validateFragmentProps(element);
2368 } else {

Callers

nothing calls this directly

Calls 11

keysMethod · 0.80
isValidElementTypeFunction · 0.70
isArrayFunction · 0.70
getComponentNameFromTypeFunction · 0.70
errorFunction · 0.70
validateChildKeysFunction · 0.70
validateFragmentPropsFunction · 0.70
validatePropTypesFunction · 0.70
applyMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…