Skip to content

Commit eeb36f4

Browse files
rubennortefacebook-github-bot
authored andcommitted
Improve display names of root components in React Profiler
Summary: Changelog: [General][Added] - Added `debugName` parameter to `renderApplication` to use as the display name for the React root tree Reviewed By: rickhanlonii Differential Revision: D26637787 fbshipit-source-id: 3ddc037573f4434101a9d3dcb5592a127193481c
1 parent 468bc62 commit eeb36f4

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Libraries/ReactNative/AppRegistry.js

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ const AppRegistry = {
124124
showArchitectureIndicator,
125125
scopedPerformanceLogger,
126126
appKey === 'LogBox',
127+
appKey,
127128
);
128129
},
129130
};

Libraries/ReactNative/renderApplication.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@ function renderApplication<Props: Object>(
2828
showArchitectureIndicator?: boolean,
2929
scopedPerformanceLogger?: IPerformanceLogger,
3030
isLogBox?: boolean,
31+
debugName?: string,
3132
) {
3233
invariant(rootTag, 'Expect to have a valid rootTag, instead got ', rootTag);
3334

3435
const performanceLogger = scopedPerformanceLogger ?? GlobalPerformanceLogger;
3536

36-
const renderable = (
37+
let renderable = (
3738
<PerformanceLoggerContext.Provider value={performanceLogger}>
3839
<AppContainer
3940
rootTag={rootTag}
@@ -47,6 +48,16 @@ function renderApplication<Props: Object>(
4748
</PerformanceLoggerContext.Provider>
4849
);
4950

51+
if (__DEV__ && debugName) {
52+
const RootComponentWithMeaningfulName = ({children}) => children;
53+
RootComponentWithMeaningfulName.displayName = `${debugName}(RootComponent)`;
54+
renderable = (
55+
<RootComponentWithMeaningfulName>
56+
{renderable}
57+
</RootComponentWithMeaningfulName>
58+
);
59+
}
60+
5061
performanceLogger.startTimespan('renderApplication_React_render');
5162
performanceLogger.setExtra('usedReactFabric', fabric ? '1' : '0');
5263

0 commit comments

Comments
 (0)