[ReactNative] cleanup native components

This commit is contained in:
Spencer Ahrens
2015-07-24 18:31:55 -07:00
parent 53222f0dda
commit f1bd1cbc94
8 changed files with 49 additions and 59 deletions

View File

@@ -14,16 +14,24 @@
var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes');
var View = require('View');
export type ComponentInterface = ReactClass<any, any, any> | {
name?: string;
displayName?: string;
propTypes: Object;
};
function verifyPropTypes(
component: Function,
componentInterface: ComponentInterface,
viewConfig: Object,
nativePropsToIgnore?: Object
nativePropsToIgnore?: ?Object
) {
if (!viewConfig) {
return; // This happens for UnimplementedView.
}
var componentName = component.name || component.displayName;
if (!component.propTypes) {
var componentName = componentInterface.name ||
componentInterface.displayName ||
'unknown';
if (!componentInterface.propTypes) {
throw new Error(
'`' + componentName + '` has no propTypes defined`'
);
@@ -31,7 +39,7 @@ function verifyPropTypes(
var nativeProps = viewConfig.NativeProps;
for (var prop in nativeProps) {
if (!component.propTypes[prop] &&
if (!componentInterface.propTypes[prop] &&
!View.propTypes[prop] &&
!ReactNativeStyleAttributes[prop] &&
(!nativePropsToIgnore || !nativePropsToIgnore[prop])) {