react-native/Libraries/ReactIOS/renderApplication.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2015-01-29 17:10:49 -08:00
/**
* 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.
2015-01-29 17:10:49 -08:00
*
* @providesModule renderApplication
2015-03-24 19:34:12 -07:00
* @flow
2015-01-29 17:10:49 -08:00
*/
'use strict';
var Portal = require('Portal');
2015-01-29 17:10:49 -08:00
var React = require('React');
var StyleSheet = require('StyleSheet');
var View = require('View');
2015-01-29 17:10:49 -08:00
var invariant = require('invariant');
2015-03-24 19:34:12 -07:00
function renderApplication<D, P, S>(
RootComponent: ReactClass<D, P, S>,
initialProps: P,
rootTag: any
) {
2015-01-29 17:10:49 -08:00
invariant(
rootTag,
'Expect to have a valid rootTag, instead got ', rootTag
);
React.render(
<View style={styles.appContainer}>
<RootComponent
{...initialProps}
/>
<Portal />
</View>,
rootTag
);
2015-01-29 17:10:49 -08:00
}
var styles = StyleSheet.create({
// This is needed so the application covers the whole screen
// and therefore the contents of the Portal are not clipped.
appContainer: {
position: 'absolute',
left: 0,
top: 0,
right: 0,
bottom: 0,
},
});
2015-01-29 17:10:49 -08:00
module.exports = renderApplication;