MCPcopy Create free account
hub / github.com/Lucifier129/react-lite / createPrimitiveTypeChecker

Function createPrimitiveTypeChecker

examples/simple/react.js:12528–12544  ·  view source on GitHub ↗
(expectedType)

Source from the content-addressed store, hash-verified

12526}
12527
12528function createPrimitiveTypeChecker(expectedType) {
12529 function validate(props, propName, componentName, location, propFullName) {
12530 var propValue = props[propName];
12531 var propType = getPropType(propValue);
12532 if (propType !== expectedType) {
12533 var locationName = ReactPropTypeLocationNames[location];
12534 // `propValue` being instance of, say, date/regexp, pass the 'object'
12535 // check, but we can offer a more precise error message here rather than
12536 // 'of type `object`'.
12537 var preciseType = getPreciseType(propValue);
12538
12539 return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
12540 }
12541 return null;
12542 }
12543 return createChainableTypeChecker(validate);
12544}
12545
12546function createAnyTypeChecker() {
12547 return createChainableTypeChecker(emptyFunction.thatReturns(null));

Callers 1

react.jsFile · 0.85

Calls 1

Tested by

no test coverage detected