mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-12 19:48:30 +08:00
Introduce PerformanceLoggerContext and use it with renderApplication
Reviewed By: sahrens Differential Revision: D14167646 fbshipit-source-id: 3f8dd27ba1c8866471e2af493c4cc0bc84706042
This commit is contained in:
committed by
Facebook Github Bot
parent
1aabbf5dce
commit
60640485e1
@@ -11,7 +11,9 @@
|
||||
'use strict';
|
||||
|
||||
const AppContainer = require('AppContainer');
|
||||
import PerformanceLogger from 'GlobalPerformanceLogger';
|
||||
import GlobalPerformanceLogger from 'GlobalPerformanceLogger';
|
||||
import type {IPerformanceLogger} from 'createPerformanceLogger';
|
||||
import PerformanceLoggerContext from 'PerformanceLoggerContext';
|
||||
const React = require('React');
|
||||
const ReactFabricIndicator = require('ReactFabricIndicator');
|
||||
|
||||
@@ -27,16 +29,20 @@ function renderApplication<Props: Object>(
|
||||
WrapperComponent?: ?React.ComponentType<*>,
|
||||
fabric?: boolean,
|
||||
showFabricIndicator?: boolean,
|
||||
scopedPerformanceLogger?: IPerformanceLogger,
|
||||
) {
|
||||
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>
|
||||
<PerformanceLoggerContext.Provider
|
||||
value={scopedPerformanceLogger ?? GlobalPerformanceLogger}>
|
||||
<AppContainer rootTag={rootTag} WrapperComponent={WrapperComponent}>
|
||||
<RootComponent {...initialProps} rootTag={rootTag} />
|
||||
{fabric === true && showFabricIndicator === true ? (
|
||||
<ReactFabricIndicator />
|
||||
) : null}
|
||||
</AppContainer>
|
||||
</PerformanceLoggerContext.Provider>
|
||||
);
|
||||
|
||||
// If the root component is async, the user probably wants the initial render
|
||||
@@ -54,13 +60,13 @@ function renderApplication<Props: Object>(
|
||||
renderable = <ConcurrentMode>{renderable}</ConcurrentMode>;
|
||||
}
|
||||
|
||||
PerformanceLogger.startTimespan('renderApplication_React_render');
|
||||
GlobalPerformanceLogger.startTimespan('renderApplication_React_render');
|
||||
if (fabric) {
|
||||
require('ReactFabric').render(renderable, rootTag);
|
||||
} else {
|
||||
require('ReactNative').render(renderable, rootTag);
|
||||
}
|
||||
PerformanceLogger.stopTimespan('renderApplication_React_render');
|
||||
GlobalPerformanceLogger.stopTimespan('renderApplication_React_render');
|
||||
}
|
||||
|
||||
module.exports = renderApplication;
|
||||
|
||||
Reference in New Issue
Block a user