diff --git a/Libraries/ReactIOS/AppContainer.js b/Libraries/ReactIOS/AppContainer.js new file mode 100644 index 000000000..43ecd2ef7 --- /dev/null +++ b/Libraries/ReactIOS/AppContainer.js @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2015-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + * + * @providesModule AppContainer + * @noflow + */ + +'use strict'; + +var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +var React = require('React'); +var ReactNative = require('ReactNative'); +var Subscribable = require('Subscribable'); +var StyleSheet = require('StyleSheet'); +var View = require('View'); + +var Inspector = __DEV__ ? require('Inspector') : null; +var YellowBox = __DEV__ ? require('YellowBox') : null; + +var AppContainer = React.createClass({ + mixins: [Subscribable.Mixin], + + getInitialState: function() { + return { inspector: null, mainKey: 1 }; + }, + + toggleElementInspector: function() { + var inspector = !__DEV__ || this.state.inspector + ? null + : { + this.setState( + (s) => ({mainKey: s.mainKey + 1}), + () => updateInspectedViewTag(ReactNative.findNodeHandle(this.refs.main)) + ); + }} + />; + this.setState({inspector}); + }, + + componentDidMount: function() { + this.addListenerOn( + RCTDeviceEventEmitter, + 'toggleElementInspector', + this.toggleElementInspector + ); + }, + + render: function() { + let yellowBox = null; + if (__DEV__) { + yellowBox = ; + } + return ( + + + {this.props.children} + + {yellowBox} + {this.state.inspector} + + ); + } +}); + +var styles = StyleSheet.create({ + appContainer: { + flex: 1, + }, +}); + +module.exports = AppContainer; diff --git a/Libraries/ReactIOS/renderApplication.ios.js b/Libraries/ReactIOS/renderApplication.ios.js index 1a7512800..cc6f7292f 100644 --- a/Libraries/ReactIOS/renderApplication.ios.js +++ b/Libraries/ReactIOS/renderApplication.ios.js @@ -7,75 +7,18 @@ * of patent rights can be found in the PATENTS file in the same directory. * * @providesModule renderApplication - * @noflow + * @flow */ 'use strict'; -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); +var AppContainer = require('AppContainer'); var React = require('React'); var ReactNative = require('ReactNative'); -var StyleSheet = require('StyleSheet'); -var Subscribable = require('Subscribable'); -var View = require('View'); var invariant = require('fbjs/lib/invariant'); -var Inspector = __DEV__ ? require('Inspector') : null; -var YellowBox = __DEV__ ? require('YellowBox') : null; - -var AppContainer = React.createClass({ - mixins: [Subscribable.Mixin], - - getInitialState: function() { - return { inspector: null, mainKey: 1 }; - }, - - toggleElementInspector: function() { - var inspector = !__DEV__ || this.state.inspector - ? null - : { - this.setState( - (s) => ({mainKey: s.mainKey + 1}), - () => updateInspectedViewTag(ReactNative.findNodeHandle(this.refs.main)) - ); - }} - />; - this.setState({inspector}); - }, - - componentDidMount: function() { - this.addListenerOn( - RCTDeviceEventEmitter, - 'toggleElementInspector', - this.toggleElementInspector - ); - }, - - render: function() { - let yellowBox = null; - if (__DEV__) { - yellowBox = ; - } - return ( - - - {this.props.children} - - {yellowBox} - {this.state.inspector} - - ); - } -}); - -function renderApplication( +function renderApplication

( RootComponent: ReactClass

, initialProps: P, rootTag: any @@ -84,7 +27,6 @@ function renderApplication( rootTag, 'Expect to have a valid rootTag, instead got ', rootTag ); - /* eslint-disable jsx-no-undef-with-namespace */ ReactNative.render( ( , rootTag ); - /* eslint-enable jsx-no-undef-with-namespace */ } -var styles = StyleSheet.create({ - appContainer: { - flex: 1, - }, -}); module.exports = renderApplication;