Skip to content

Commit

Permalink
Don't read currentTransition back from internals (#30991)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sebmarkbage authored Sep 17, 2024
1 parent 4549be0 commit 15da917
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/react/src/ReactStartTransition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand All @@ -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' &&
Expand Down

0 comments on commit 15da917

Please sign in to comment.