fix: initialize transition start time with performance.now() #35726
+8
−6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Details
packages/react/src/ReactStartTransition.js: Added anow()helper (usingperformance.now()with aDate.now()fallback) and used it to setcurrentTransition.startTime.packages/react-reconciler/src/ReactFiberWorkLoop.js: Removed the check fortransition.startTime === -1and the subsequent assignment, as it is no longer needed.Motivation
Previously,
startTimewas initialized to-1and lazily updated upon scheduling an update. This behavior was inconsistent withuseTransitionand could lead to inaccurate timestamps if there was a delay between the transition start and the actual update scheduling. This change standardizes the behavior and ensures accurate timing for transition tracing.How to Test
enableTransitionTracingfeature flag.yarn test ReactTransitionTracing.Checklist
yarn test ReactTransitionTracing).Fixes #35725