Skip to content

Commit

Permalink
fix exception when ES6 class with no propTypes defined before calling…
Browse files Browse the repository at this point in the history
… requireNativeComponent

Summary:
Closes #1260
Github Author: Luke <kejinlu@gmail.com>

Test Plan: Created `class Foo extends React.Component` and made sure error messages were good.
  • Loading branch information
kejinlu committed May 18, 2015
1 parent 03905e6 commit de27f1d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Libraries/ReactIOS/verifyPropTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,23 @@ function verifyPropTypes(
if (!viewConfig) {
return; // This happens for UnimplementedView.
}
var componentName = component.name || component.displayName;
if (!component.propTypes) {
throw new Error(
'`' + componentName + '` has no propTypes defined`'
);
}

var nativeProps = viewConfig.nativeProps;
for (var prop in nativeProps) {
if (!component.propTypes[prop] &&
!View.propTypes[prop] &&
!ReactNativeStyleAttributes[prop] &&
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {
throw new Error(
'`' + component.displayName + '` has no propType for native prop `' +
'`' + componentName + '` has no propType for native prop `' +
viewConfig.uiViewClassName + '.' + prop + '` of native type `' +
nativeProps[prop].type + '`'
nativeProps[prop] + '`'
);
}
}
Expand Down

0 comments on commit de27f1d

Please sign in to comment.