From 2a1903d98e4c4c3bd1c7ac296874c6ee416c69cc Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Sun, 15 Sep 2024 23:31:42 -0400 Subject: [PATCH] Feature test --- .../src/ReactFiberPerformanceTrack.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js index 26084ea1cbc6a..2058a04e47454 100644 --- a/packages/react-reconciler/src/ReactFiberPerformanceTrack.js +++ b/packages/react-reconciler/src/ReactFiberPerformanceTrack.js @@ -13,6 +13,14 @@ import getComponentNameFromFiber from './getComponentNameFromFiber'; import {getGroupNameOfHighestPriorityLane} from './ReactFiberLane'; +import {enableProfilerTimer} from 'shared/ReactFeatureFlags'; + +const supportsUserTiming = + enableProfilerTimer && + typeof performance !== 'undefined' && + // $FlowFixMe[method-unbinding] + typeof performance.measure === 'function'; + const TRACK_GROUP = 'Components ⚛'; // Reused to avoid thrashing the GC. @@ -45,7 +53,9 @@ export function logComponentRender( // Skip return; } - reusableComponentOptions.start = startTime; - reusableComponentOptions.end = endTime; - performance.measure(name, reusableComponentOptions); + if (supportsUserTiming) { + reusableComponentOptions.start = startTime; + reusableComponentOptions.end = endTime; + performance.measure(name, reusableComponentOptions); + } }