mirror of
https://github.com/status-im/react-native.git
synced 2025-02-24 15:18:10 +00:00
Summary: Adding some more systrace markers to track load application and the initial bits of MarketplaceHomeApp. There are a couple big segments worth pointing out with timing from a local `__DEV__: false` run: * JSBundleRequireTime_end -> BundlePreInitializeCore_start: 360ms * MobileConfigModuleInit: 210ms * renderApplication_React_render_start -> MarketplaceHomeAppConstructorSuper_start: 180ms * MarketplaceHomeAppGetQueryParamsForCachedTopPicks: 100ms I'm not sure what we can do about any of these except for MarketplaceHomeAppGetQueryParamsForCachedTopPicks where we could break the query params out into a separate file so we don't have to load this 11-thousand-line behemoth just so we can get this snippet: diffusion/FBS/browse/master/xplat/js/RKJSModules/Apps/Wilde/Marketplace/apps/__generated__/MarketplaceHomeAppQuery.graphql.js$11831-11837 But maybe we have to load it anyway and the query just needs to be optimized (or maybe Relay can optimize the format here). Reviewed By: yungsters Differential Revision: D13969695 fbshipit-source-id: 4f39efa6cb591b814687bfe51b02ad92048f1c21
67 lines
2.2 KiB
JavaScript
67 lines
2.2 KiB
JavaScript
/**
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*
|
|
* @format
|
|
* @flow
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
const AppContainer = require('AppContainer');
|
|
import PerformanceLogger from 'PerformanceLogger';
|
|
const React = require('React');
|
|
const ReactFabricIndicator = require('ReactFabricIndicator');
|
|
|
|
const invariant = require('invariant');
|
|
|
|
// require BackHandler so it sets the default handler that exits the app if no listeners respond
|
|
require('BackHandler');
|
|
|
|
function renderApplication<Props: Object>(
|
|
RootComponent: React.ComponentType<Props>,
|
|
initialProps: Props,
|
|
rootTag: any,
|
|
WrapperComponent?: ?React.ComponentType<*>,
|
|
fabric?: boolean,
|
|
showFabricIndicator?: boolean,
|
|
) {
|
|
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
|
|
|
|
let renderable = (
|
|
<AppContainer rootTag={rootTag} WrapperComponent={WrapperComponent}>
|
|
<RootComponent {...initialProps} rootTag={rootTag} />
|
|
{fabric === true && showFabricIndicator === true ? (
|
|
<ReactFabricIndicator />
|
|
) : null}
|
|
</AppContainer>
|
|
);
|
|
|
|
// If the root component is async, the user probably wants the initial render
|
|
// to be async also. To do this, wrap AppContainer with an async marker.
|
|
// For more info see https://fb.me/is-component-async
|
|
if (
|
|
/* $FlowFixMe(>=0.68.0 site=react_native_fb) This comment suppresses an
|
|
* error found when Flow v0.68 was deployed. To see the error delete this
|
|
* comment and run Flow. */
|
|
RootComponent.prototype != null &&
|
|
RootComponent.prototype.unstable_isAsyncReactComponent === true
|
|
) {
|
|
// $FlowFixMe This is not yet part of the official public API
|
|
const ConcurrentMode = React.unstable_ConcurrentMode;
|
|
renderable = <ConcurrentMode>{renderable}</ConcurrentMode>;
|
|
}
|
|
|
|
PerformanceLogger.startTimespan('renderApplication_React_render');
|
|
if (fabric) {
|
|
require('ReactFabric').render(renderable, rootTag);
|
|
} else {
|
|
require('ReactNative').render(renderable, rootTag);
|
|
}
|
|
PerformanceLogger.stopTimespan('renderApplication_React_render');
|
|
}
|
|
|
|
module.exports = renderApplication;
|