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.
Sebastian Markbåge committed
Sep 17, 2024 at 15:25 UTC
15da9174518f18f82869767ebe2a21be2fc8bd90
1 file changed
+6
-9
packages/react/src/ReactStartTransition.js
+6
-9
@@ -23,20 +23,17 @@ export function startTransition(
23
options?: StartTransitionOptions,
24
) {
25
const prevTransition = ReactSharedInternals.T;
26
- const transition: BatchConfigTransition = {};
27
- ReactSharedInternals.T = transition;
28
- const currentTransition = ReactSharedInternals.T;
26
+ const currentTransition: BatchConfigTransition = {};
27
+ ReactSharedInternals.T = currentTransition;
28
29
if (__DEV__) {
31
- ReactSharedInternals.T._updatedFibers = new Set();
30
+ currentTransition._updatedFibers = new Set();
31
}
32
33
if (enableTransitionTracing) {
34
if (options !== undefined && options.name !== undefined) {
36
- // $FlowFixMe[incompatible-use] found when upgrading Flow
37
- ReactSharedInternals.T.name = options.name;
38
- // $FlowFixMe[incompatible-use] found when upgrading Flow
39
- ReactSharedInternals.T.startTime = -1;
35
+ currentTransition.name = options.name;
36
+ currentTransition.startTime = -1;
37
}
38
}
39
@@ -45,7 +42,7 @@ export function startTransition(
42
const returnValue = scope();
43
const onStartTransitionFinish = ReactSharedInternals.S;
44
if (onStartTransitionFinish !== null) {
48
- onStartTransitionFinish(transition, returnValue);
45
+ onStartTransitionFinish(currentTransition, returnValue);
46
}
47
if (
48
typeof returnValue === 'object' &&