better error message for `propTypes` check

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
This commit is contained in:
Martin Kralik 2015-12-09 04:04:23 -08:00 committed by facebook-github-bot-4
parent 8d397b4cbc
commit 14478f6701
1 changed files with 9 additions and 4 deletions

View File

@ -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);
}
}
}