[react-native] Support returning null from a component

This commit is contained in:
Ben Alpert 2015-03-31 01:25:15 -07:00
parent 42689c44fd
commit 19969149ad
2 changed files with 10 additions and 4 deletions

View File

@ -12,7 +12,9 @@
var NativeMethodsMixin = require('NativeMethodsMixin');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var ReactClass = require('ReactClass');
var ReactElement = require('ReactElement');
var ReactIOSComponentMixin = require('ReactIOSComponentMixin');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var StyleSheetPropType = require('StyleSheetPropType');
var ViewStylePropTypes = require('ViewStylePropTypes');
@ -42,8 +44,8 @@ var stylePropType = StyleSheetPropType(ViewStylePropTypes);
* `View`s are designed to be used with `StyleSheet`s for clarity and
* performance, although inline styles are also supported.
*/
var View = React.createClass({
mixins: [NativeMethodsMixin],
var View = ReactClass.createClass({
mixins: [NativeMethodsMixin, ReactIOSComponentMixin],
/**
* `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We
@ -138,7 +140,7 @@ var View = React.createClass({
},
render: function() {
return <RCTView {...this.props} />;
return ReactElement.createElement(RCTView, this.props);
},
});

View File

@ -24,6 +24,7 @@ var NodeHandle = require('NodeHandle');
var ReactClass = require('ReactClass');
var ReactComponentEnvironment = require('ReactComponentEnvironment');
var ReactDefaultBatchingStrategy = require('ReactDefaultBatchingStrategy');
var ReactEmptyComponent = require('ReactEmptyComponent');
var ReactInstanceHandles = require('ReactInstanceHandles');
var ReactIOSComponentEnvironment = require('ReactIOSComponentEnvironment');
var ReactIOSComponentMixin = require('ReactIOSComponentMixin');
@ -35,6 +36,7 @@ var ReactNativeComponent = require('ReactNativeComponent');
var ReactUpdates = require('ReactUpdates');
var ResponderEventPlugin = require('ResponderEventPlugin');
var UniversalWorkerNodeHandle = require('UniversalWorkerNodeHandle');
var View = require('View');
// Just to ensure this gets packaged, since its only caller is from Native.
require('RCTEventEmitter');
@ -77,6 +79,8 @@ function inject() {
ReactIOSComponentEnvironment
);
ReactEmptyComponent.injection.injectEmptyComponent(View);
EventPluginUtils.injection.injectMount(ReactIOSMount);
ReactClass.injection.injectMixin(ReactIOSComponentMixin);