Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0e10ee9

Browse files
authored
[Reconciler] Set ProfileMode for Host Root Fiber by default in dev (facebook#34432)
Requiring DevTools to be present for dev builds seems like an overkill, let's enable the instrumentation by default. Nothing changes for profiling or production artifacts.
1 parent 0c813c5 commit 0e10ee9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/react-reconciler/src/ReactFiber.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,10 @@ export function createHostRootFiber(
532532
mode = NoMode;
533533
}
534534

535-
if (enableProfilerTimer && isDevToolsPresent) {
536-
// Always collect profile timings when DevTools are present.
537-
// This enables DevTools to start capturing timing at any point–
538-
// Without some nodes in the tree having empty base times.
535+
if (__DEV__ || (enableProfilerTimer && isDevToolsPresent)) {
536+
// dev: Enable profiling instrumentation by default.
537+
// profile: enabled if DevTools is present or subtree is wrapped in <Profiler>.
538+
// production: disabled.
539539
mode |= ProfileMode;
540540
}
541541

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ describe(`onRender`, () => {
125125
expect(callback).toHaveBeenCalledTimes(1);
126126
});
127127

128+
// @gate !__DEV__
128129
it('does not record times for components outside of Profiler tree', async () => {
129130
// Mock the Scheduler module so we can track how many times the current
130131
// time is read

0 commit comments

Comments
 (0)