Skip to content

Commit

Permalink
better error message for propTypes check
Browse files Browse the repository at this point in the history
Summary:
When you did a typo in declaring a prop type (like using `boolean` insteal of `bool`) you'd got a bit misleading error message:
{F27113768}
The truth is that the prop type is defined, but not correctly. So I've changed the message in this case to be more accurate:
{F27113627}

public

Reviewed By: sahrens

Differential Revision: D2729340

fb-gh-sync-id: dd12c10a4f3a1c9825293f86481a082908127a76
  • Loading branch information
majak authored and facebook-github-bot-4 committed Dec 9, 2015
1 parent 8d397b4 commit 14478f6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions Libraries/ReactIOS/verifyPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ function verifyPropTypes(
if (!componentInterface.propTypes[prop] &&
!ReactNativeStyleAttributes[prop] &&
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
throw new Error(
'`' + componentName + '` has no propType for native prop `' +
var message;
if (componentInterface.propTypes.hasOwnProperty(prop)) {
message = '`' + componentName + '` has incorrectly defined propType for native prop `' +
viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop];
} else {
message = '`' + componentName + '` has no propType for native prop `' +
viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
nativeProps[prop] + '`'
);
nativeProps[prop] + '`';
};
throw new Error(message);
}
}
}
Expand Down

0 comments on commit 14478f6

Please sign in to comment.