* 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)
| 1661 | * @private |
| 1662 | */ |
| 1663 | function checkPropTypes(typeSpecs, values, location, componentName, getStack) { |
| 1664 | { |
| 1665 | for (var typeSpecName in typeSpecs) { |
| 1666 | if (has(typeSpecs, typeSpecName)) { |
| 1667 | var error; |
| 1668 | // Prop type validation may throw. In case they do, we don't want to |
| 1669 | // fail the render phase where it didn't fail before. So we log it. |
| 1670 | // After these have been cleaned up, we'll let them throw. |
| 1671 | try { |
| 1672 | // This is intentionally an invariant that gets caught. It's the same |
| 1673 | // behavior as without this statement except with a better message. |
| 1674 | if (typeof typeSpecs[typeSpecName] !== 'function') { |
| 1675 | var err = Error( |
| 1676 | (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' + |
| 1677 | 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.' |
| 1678 | ); |
| 1679 | err.name = 'Invariant Violation'; |
| 1680 | throw err; |
| 1681 | } |
| 1682 | error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1); |
| 1683 | } catch (ex) { |
| 1684 | error = ex; |
| 1685 | } |
| 1686 | if (error && !(error instanceof Error)) { |
| 1687 | printWarning$1( |
| 1688 | (componentName || 'React class') + ': type specification of ' + |
| 1689 | location + ' `' + typeSpecName + '` is invalid; the type checker ' + |
| 1690 | 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' + |
| 1691 | 'You may have forgotten to pass an argument to the type checker ' + |
| 1692 | 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + |
| 1693 | 'shape all require an argument).' |
| 1694 | ); |
| 1695 | } |
| 1696 | if (error instanceof Error && !(error.message in loggedTypeFailures)) { |
| 1697 | // Only monitor this failure once because there tends to be a lot of the |
| 1698 | // same error. |
| 1699 | loggedTypeFailures[error.message] = true; |
| 1700 | |
| 1701 | var stack = getStack ? getStack() : ''; |
| 1702 | |
| 1703 | printWarning$1( |
| 1704 | 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '') |
| 1705 | ); |
| 1706 | } |
| 1707 | } |
| 1708 | } |
| 1709 | } |
| 1710 | } |
| 1711 | |
| 1712 | /** |
| 1713 | * Resets warning cache when testing. |
nothing calls this directly
no test coverage detected