/** * 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 renderApplication */ 'use strict'; var Inspector = require('Inspector'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); 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 YellowBox = __DEV__ ? require('YellowBox') : null; // require BackAndroid so it sets the default handler that exits the app if no listeners respond require('BackAndroid'); var AppContainer = React.createClass({ mixins: [Subscribable.Mixin], getInitialState: function() { return { inspectorVisible: false, rootNodeHandle: null, rootImportanceForAccessibility: 'auto', mainKey: 1, }; }, toggleElementInspector: function() { this.setState({ inspectorVisible: !this.state.inspectorVisible, rootNodeHandle: ReactNative.findNodeHandle(this.refs.main), }); }, componentDidMount: function() { this.addListenerOn( RCTDeviceEventEmitter, 'toggleElementInspector', this.toggleElementInspector ); this._unmounted = false; }, renderInspector: function() { return this.state.inspectorVisible ? { this.setState( (s) => ({mainKey: s.mainKey + 1}), () => updateInspectedViewTag(ReactNative.findNodeHandle(this.refs.main)) ); }} /> : null; }, componentWillUnmount: function() { this._unmounted = true; }, render: function() { var RootComponent = this.props.rootComponent; var appView = ; return __DEV__ ? {appView} {this.renderInspector()} : appView; } }); function renderApplication( RootComponent: ReactClass

, initialProps: P, rootTag: any ) { invariant( rootTag, 'Expect to have a valid rootTag, instead got ', rootTag ); ReactNative.render( , rootTag ); } var styles = StyleSheet.create({ appContainer: { position: 'absolute', left: 0, top: 0, right: 0, bottom: 0, }, }); module.exports = renderApplication;