mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
fix exception when ES6 class with no propTypes defined before calling requireNativeComponent
Summary: Closes https://github.com/facebook/react-native/pull/1260 Github Author: Luke <kejinlu@gmail.com> Test Plan: Created `class Foo extends React.Component` and made sure error messages were good.
This commit is contained in:
parent
03905e69f4
commit
de27f1db54
@ -22,6 +22,13 @@ 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] &&
|
||||
@ -29,9 +36,9 @@ function verifyPropTypes(
|
||||
!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] + '`'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user