2015-02-20 04:10:52 +00:00
|
|
|
/**
|
2015-03-23 20:35:08 +00: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-02-20 04:10:52 +00:00
|
|
|
*
|
|
|
|
* @providesModule renderApplication
|
2017-06-26 23:20:39 +00:00
|
|
|
* @format
|
2016-06-08 21:30:46 +00:00
|
|
|
* @flow
|
2015-02-20 04:10:52 +00:00
|
|
|
*/
|
2015-11-20 21:05:34 +00:00
|
|
|
|
2015-02-20 04:10:52 +00:00
|
|
|
'use strict';
|
|
|
|
|
2017-06-26 23:20:39 +00:00
|
|
|
const AppContainer = require('AppContainer');
|
|
|
|
const React = require('React');
|
|
|
|
const ReactNative = require('ReactNative');
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2017-06-26 23:20:39 +00:00
|
|
|
const invariant = require('fbjs/lib/invariant');
|
2015-02-20 04:10:52 +00:00
|
|
|
|
2017-03-07 05:41:51 +00:00
|
|
|
// require BackHandler so it sets the default handler that exits the app if no listeners respond
|
|
|
|
require('BackHandler');
|
2016-06-13 23:34:48 +00:00
|
|
|
|
2016-11-15 04:39:21 +00:00
|
|
|
function renderApplication<Props: Object>(
|
2016-06-13 23:34:48 +00:00
|
|
|
RootComponent: ReactClass<Props>,
|
|
|
|
initialProps: Props,
|
2017-06-26 23:20:39 +00:00
|
|
|
rootTag: any,
|
|
|
|
WrapperComponent?: ?ReactClass<*>,
|
2015-03-24 18:30:58 +00:00
|
|
|
) {
|
2017-06-26 23:20:39 +00:00
|
|
|
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
|
|
|
|
|
2016-04-08 02:43:49 +00:00
|
|
|
ReactNative.render(
|
2017-06-28 01:08:05 +00:00
|
|
|
<AppContainer rootTag={rootTag} WrapperComponent={WrapperComponent}>
|
2017-06-26 23:20:39 +00:00
|
|
|
<RootComponent {...initialProps} rootTag={rootTag} />
|
2015-05-26 18:16:25 +00:00
|
|
|
</AppContainer>,
|
2017-06-26 23:20:39 +00:00
|
|
|
rootTag,
|
2015-03-11 20:25:40 +00:00
|
|
|
);
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = renderApplication;
|