Skip to content

Commit 2a1903d

Browse files
committed
Feature test
1 parent b03e3ee commit 2a1903d

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

packages/react-reconciler/src/ReactFiberPerformanceTrack.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import getComponentNameFromFiber from './getComponentNameFromFiber';
1313

1414
import {getGroupNameOfHighestPriorityLane} from './ReactFiberLane';
1515

16+
import {enableProfilerTimer} from 'shared/ReactFeatureFlags';
17+
18+
const supportsUserTiming =
19+
enableProfilerTimer &&
20+
typeof performance !== 'undefined' &&
21+
// $FlowFixMe[method-unbinding]
22+
typeof performance.measure === 'function';
23+
1624
const TRACK_GROUP = 'Components ⚛';
1725

1826
// Reused to avoid thrashing the GC.
@@ -45,7 +53,9 @@ export function logComponentRender(
4553
// Skip
4654
return;
4755
}
48-
reusableComponentOptions.start = startTime;
49-
reusableComponentOptions.end = endTime;
50-
performance.measure(name, reusableComponentOptions);
56+
if (supportsUserTiming) {
57+
reusableComponentOptions.start = startTime;
58+
reusableComponentOptions.end = endTime;
59+
performance.measure(name, reusableComponentOptions);
60+
}
5161
}

0 commit comments

Comments
 (0)