File tree Expand file tree Collapse file tree 2 files changed +50
-4
lines changed
packages/react-reconciler/src Expand file tree Collapse file tree 2 files changed +50
-4
lines changed Original file line number Diff line number Diff line change @@ -2389,11 +2389,11 @@ function startTransition(
2389
2389
higherEventPriority ( previousPriority , ContinuousEventPriority ) ,
2390
2390
) ;
2391
2391
2392
- setPending ( true ) ;
2393
-
2394
2392
const prevTransition = ReactCurrentBatchConfig . transition ;
2395
- ReactCurrentBatchConfig . transition = ( { } : BatchConfigTransition ) ;
2396
- const currentTransition = ReactCurrentBatchConfig . transition ;
2393
+ ReactCurrentBatchConfig . transition = null ;
2394
+ setPending ( true ) ;
2395
+ const currentTransition = ( ReactCurrentBatchConfig . transition =
2396
+ ( { } : BatchConfigTransition ) ) ;
2397
2397
2398
2398
if ( enableTransitionTracing ) {
2399
2399
if ( options !== undefined && options . name !== undefined ) {
Original file line number Diff line number Diff line change @@ -951,4 +951,50 @@ describe('ReactTransition', () => {
951
951
952
952
expect ( root ) . toMatchRenderedOutput ( 'Transition pri: 1, Normal pri: 1' ) ;
953
953
} ) ;
954
+
955
+ it ( 'tracks two pending flags for nested startTransition (#26226)' , async ( ) => {
956
+ let update ;
957
+ function App ( ) {
958
+ const [ isPendingA , startTransitionA ] = useTransition ( ) ;
959
+ const [ isPendingB , startTransitionB ] = useTransition ( ) ;
960
+ const [ state , setState ] = useState ( 0 ) ;
961
+
962
+ update = function ( ) {
963
+ startTransitionA ( ( ) => {
964
+ startTransitionB ( ( ) => {
965
+ setState ( 1 ) ;
966
+ } ) ;
967
+ } ) ;
968
+ } ;
969
+
970
+ return (
971
+ < >
972
+ < Text text = { state } />
973
+ { ', ' }
974
+ < Text text = { 'A ' + isPendingA } />
975
+ { ', ' }
976
+ < Text text = { 'B ' + isPendingB } />
977
+ </ >
978
+ ) ;
979
+ }
980
+ const root = ReactNoop . createRoot ( ) ;
981
+ await act ( async ( ) => {
982
+ root . render ( < App /> ) ;
983
+ } ) ;
984
+ assertLog ( [ 0 , 'A false' , 'B false' ] ) ;
985
+ expect ( root ) . toMatchRenderedOutput ( '0, A false, B false' ) ;
986
+
987
+ await act ( async ( ) => {
988
+ update ( ) ;
989
+ } ) ;
990
+ assertLog ( [
991
+ 0 ,
992
+ 'A true' ,
993
+ 'B true' ,
994
+ 1 ,
995
+ 'A false' ,
996
+ 'B false' ,
997
+ ] ) ;
998
+ expect ( root ) . toMatchRenderedOutput ( '1, A false, B false' ) ;
999
+ } ) ;
954
1000
} ) ;
You can’t perform that action at this time.
0 commit comments