MCPcopy
hub / github.com/plotly/dash / checkPropTypes

Function checkPropTypes

dash/deps/react-dom@18.2.0.js:11668–11715  ·  view source on GitHub ↗
(typeSpecs, values, location, componentName, element)

Source from the content-addressed store, hash-verified

11666 }
11667
11668 function checkPropTypes(typeSpecs, values, location, componentName, element) {
11669 {
11670 // $FlowFixMe This is okay but Flow doesn't know it.
11671 var has = Function.call.bind(hasOwnProperty);
11672
11673 for (var typeSpecName in typeSpecs) {
11674 if (has(typeSpecs, typeSpecName)) {
11675 var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to
11676 // fail the render phase where it didn't fail before. So we log it.
11677 // After these have been cleaned up, we'll let them throw.
11678
11679 try {
11680 // This is intentionally an invariant that gets caught. It's the same
11681 // behavior as without this statement except with a better message.
11682 if (typeof typeSpecs[typeSpecName] !== 'function') {
11683 // eslint-disable-next-line react-internal/prod-error-codes
11684 var err = Error((componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' + 'This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.');
11685 err.name = 'Invariant Violation';
11686 throw err;
11687 }
11688
11689 error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED');
11690 } catch (ex) {
11691 error$1 = ex;
11692 }
11693
11694 if (error$1 && !(error$1 instanceof Error)) {
11695 setCurrentlyValidatingElement(element);
11696
11697 error('%s: type specification of %s' + ' `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error$1);
11698
11699 setCurrentlyValidatingElement(null);
11700 }
11701
11702 if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
11703 // Only monitor this failure once because there tends to be a lot of the
11704 // same error.
11705 loggedTypeFailures[error$1.message] = true;
11706 setCurrentlyValidatingElement(element);
11707
11708 error('Failed %s type: %s', location, error$1.message);
11709
11710 setCurrentlyValidatingElement(null);
11711 }
11712 }
11713 }
11714 }
11715 }
11716
11717 var valueStack = [];
11718 var fiberStack;

Callers 10

getMaskedContextFunction · 0.70
processChildContextFunction · 0.70
updateForwardRefFunction · 0.70
updateMemoComponentFunction · 0.70
updateFunctionComponentFunction · 0.70
updateClassComponentFunction · 0.70
mountLazyComponentFunction · 0.70
updateContextProviderFunction · 0.70
beginWorkFunction · 0.70

Calls 3

hasFunction · 0.70
errorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…