[react-native] Nicer error for undefined or string tag names

This commit is contained in:
Ben Alpert 2015-04-02 16:43:30 -07:00
parent 9df3e889ad
commit 03cf69dde1
1 changed files with 9 additions and 0 deletions

View File

@ -38,6 +38,7 @@ var ResponderEventPlugin = require('ResponderEventPlugin');
var UniversalWorkerNodeHandle = require('UniversalWorkerNodeHandle');
var createReactIOSNativeComponentClass = require('createReactIOSNativeComponentClass');
var invariant = require('invariant');
// Just to ensure this gets packaged, since its only caller is from Native.
require('RCTEventEmitter');
@ -94,6 +95,14 @@ function inject() {
ReactNativeComponent.injection.injectTextComponentClass(
ReactIOSTextComponent
);
ReactNativeComponent.injection.injectAutoWrapper(function(tag) {
// Show a nicer error message for non-function tags
var info = '';
if (typeof tag === 'string' && /^[a-z]/.test(tag)) {
info += ' Each component name should start with an uppercase letter.';
}
invariant(false, 'Expected a component class, got %s.%s', tag, info);
});
NodeHandle.injection.injectImplementation(UniversalWorkerNodeHandle);
}