* Assert that the values match with the type specs. * Error messages are memorized and will only be shown once. * * @param {object} typeSpecs Map of name to a ReactPropType * @param {object} values Runtime values that need to be type-checked * @param {string} location e.g. "prop", "co
(typeSpecs, values, location, componentName, getStack)
| 1700 | * @private |
| 1701 | */ |
| 1702 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) { |
| 1703 | { |
| 1704 | for (var typeSpecName in typeSpecs) { |
| 1705 | if (has(typeSpecs, typeSpecName)) { |
| 1706 | var error; |
| 1707 | // Prop type validation may throw. In case they do, we don't want to |
| 1708 | // fail the render phase where it didn't fail before. So we log it. |
| 1709 | // After these have been cleaned up, we'll let them throw. |
| 1710 | try { |
| 1711 | // This is intentionally an invariant that gets caught. It's the same |
| 1712 | // behavior as without this statement except with a better message. |
| 1713 | if (typeof typeSpecs[typeSpecName] !== 'function') { |
| 1714 | var err = Error( |
| 1715 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + |
| 1716 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' |
| 1717 | ); |
| 1718 | err.name = 'Invariant Violation'; |
| 1719 | throw err; |
| 1720 | } |
| 1721 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1); |
| 1722 | } catch (ex) { |
| 1723 | error = ex; |
| 1724 | } |
| 1725 | if (error && !(error instanceof Error)) { |
| 1726 | printWarning$1( |
| 1727 | (componentName || 'React class') + ': type specification of ' + |
| 1728 | location + ' `' + typeSpecName + '` is invalid; the type checker ' + |
| 1729 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + |
| 1730 | 'You may have forgotten to pass an argument to the type checker ' + |
| 1731 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + |
| 1732 | 'shape all require an argument).' |
| 1733 | ); |
| 1734 | } |
| 1735 | if (error instanceof Error && !(error.message in loggedTypeFailures)) { |
| 1736 | // Only monitor this failure once because there tends to be a lot of the |
| 1737 | // same error. |
| 1738 | loggedTypeFailures[error.message] = true; |
| 1739 | |
| 1740 | var stack = getStack ? getStack() : ''; |
| 1741 | |
| 1742 | printWarning$1( |
| 1743 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') |
| 1744 | ); |
| 1745 | } |
| 1746 | } |
| 1747 | } |
| 1748 | } |
| 1749 | } |
| 1750 | |
| 1751 | /** |
| 1752 | * Resets warning cache when testing. |
nothing calls this directly
no test coverage detected