Skip to content

Commit

Permalink
Don't call getPropType until error detected as it is slow for large d…
Browse files Browse the repository at this point in the history
…ata structures
  • Loading branch information
jsdf committed May 22, 2016
1 parent 0ec415e commit 9bbb3be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ImmutablePropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ function createIterableOfTypeChecker(typeChecker) {
function createRecordOfTypeChecker(recordKeys) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (!(propValue instanceof Immutable.Record)) {
var propType = getPropType(propValue);
var locationName = location;
return new Error(
`Invalid ${locationName} \`${propFullName}\` of type \`${propType}\` ` +
Expand All @@ -176,8 +176,8 @@ function createRecordOfTypeChecker(recordKeys) {
function createShapeTypeChecker(shapeTypes, immutableClassName = 'Iterable', immutableClassTypeValidator = Immutable.Iterable.isIterable) {
function validate(props, propName, componentName, location, propFullName) {
var propValue = props[propName];
var propType = getPropType(propValue);
if (!immutableClassTypeValidator(propValue)) {
var propType = getPropType(propValue);
var locationName = location;
return new Error(
`Invalid ${locationName} \`${propFullName}\` of type \`${propType}\` ` +
Expand Down

0 comments on commit 9bbb3be

Please sign in to comment.