From 15da9174518f18f82869767ebe2a21be2fc8bd90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Tue, 17 Sep 2024 15:25:00 -0400 Subject: [PATCH] Don't read currentTransition back from internals (#30991) This code is weird. It reads back the transition that it just set from the shared internals. It's almost like it expects it to be a getter or something. This avoids that and makes it consistent with what ReactFiberHooks already does. --- packages/react/src/ReactStartTransition.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/react/src/ReactStartTransition.js b/packages/react/src/ReactStartTransition.js index 6bae8947e1cea..a9b30c424a07f 100644 --- a/packages/react/src/ReactStartTransition.js +++ b/packages/react/src/ReactStartTransition.js @@ -23,20 +23,17 @@ export function startTransition( options?: StartTransitionOptions, ) { const prevTransition = ReactSharedInternals.T; - const transition: BatchConfigTransition = {}; - ReactSharedInternals.T = transition; - const currentTransition = ReactSharedInternals.T; + const currentTransition: BatchConfigTransition = {}; + ReactSharedInternals.T = currentTransition; if (__DEV__) { - ReactSharedInternals.T._updatedFibers = new Set(); + currentTransition._updatedFibers = new Set(); } if (enableTransitionTracing) { if (options !== undefined && options.name !== undefined) { - // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.name = options.name; - // $FlowFixMe[incompatible-use] found when upgrading Flow - ReactSharedInternals.T.startTime = -1; + currentTransition.name = options.name; + currentTransition.startTime = -1; } } @@ -45,7 +42,7 @@ export function startTransition( const returnValue = scope(); const onStartTransitionFinish = ReactSharedInternals.S; if (onStartTransitionFinish !== null) { - onStartTransitionFinish(transition, returnValue); + onStartTransitionFinish(currentTransition, returnValue); } if ( typeof returnValue === 'object' &&