[Reconciler] Set ProfileMode for Host Root Fiber by default in dev (#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.
Ruslan Lesiutin committed
Sep 12, 2025 at 12:20 UTC
0e10ee906e3ea55e4d717d4db498e1159235b06b
2 files changed
+5
-4
packages/react-reconciler/src/ReactFiber.js
+4
-4
@@ -532,10 +532,10 @@ export function createHostRootFiber(
532
mode = NoMode;
533
}
534
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.
539
mode |= ProfileMode;
540
}
541
packages/react/src/__tests__/ReactProfiler-test.internal.js
+1
@@ -125,6 +125,7 @@ describe(`onRender`, () => {
125
expect(callback).toHaveBeenCalledTimes(1);
126
});
127
128
+ // @gate !__DEV__
129
it('does not record times for components outside of Profiler tree', async () => {
130
// Mock the Scheduler module so we can track how many times the current
131
// time is read