@@ -776,8 +776,11 @@ export function TransitionAwareHostComponent(): boolean {
776
776
return false ;
777
777
}
778
778
const dispatcher = ReactCurrentDispatcher . current ;
779
- const [ isPending ] = dispatcher . useTransition ( ) ;
780
- return isPending ;
779
+ const [ booleanOrThenable ] = dispatcher . useState ( ) ;
780
+ return typeof booleanOrThenable === 'boolean'
781
+ ? booleanOrThenable
782
+ : // This will suspend until the async action scope has finished.
783
+ useThenable ( booleanOrThenable ) ;
781
784
}
782
785
783
786
export function checkDidRenderIdHook ( ) : boolean {
@@ -2545,8 +2548,8 @@ export function startHostTransition<F>(
2545
2548
// it was stateful all along so we can reuse most of the implementation
2546
2549
// for function components and useTransition.
2547
2550
//
2548
- // Create the initial hooks used by useTransition . This is essentially an
2549
- // inlined version of mountTransition .
2551
+ // Create the state hook used by TransitionAwareHostComponent . This is
2552
+ // essentially an inlined version of mountState .
2550
2553
const queue : UpdateQueue <
2551
2554
Thenable < boolean > | boolean ,
2552
2555
Thenable < boolean > | boolean ,
@@ -2569,32 +2572,18 @@ export function startHostTransition<F>(
2569
2572
( dispatchSetState . bind ( null , formFiber , queue ) : any ) ;
2570
2573
setPending = queue . dispatch = dispatch ;
2571
2574
2572
- // TODO: The only reason this second hook exists is to save a reference to
2573
- // the `dispatch` function. But we already store this on the state hook. So
2574
- // we can cheat and read it from there. Need to make this change to the
2575
- // regular `useTransition` implementation, too.
2576
- const transitionHook : Hook = {
2577
- memoizedState : dispatch ,
2578
- baseState : null ,
2579
- baseQueue : null ,
2580
- queue : null ,
2581
- next : null ,
2582
- } ;
2583
-
2584
- stateHook . next = transitionHook ;
2585
-
2586
- // Add the initial list of hooks to both fiber alternates. The idea is that
2587
- // the fiber had these hooks all along.
2575
+ // Add the state hook to both fiber alternates. The idea is that the fiber
2576
+ // had this hook all along.
2588
2577
formFiber . memoizedState = stateHook ;
2589
2578
const alternate = formFiber . alternate ;
2590
2579
if ( alternate !== null ) {
2591
2580
alternate . memoizedState = stateHook ;
2592
2581
}
2593
2582
} else {
2594
2583
// This fiber was already upgraded to be stateful.
2595
- const transitionHook : Hook = formFiber . memoizedState . next ;
2584
+ const stateHook : Hook = formFiber . memoizedState ;
2596
2585
const dispatch : ( Thenable < boolean > | boolean ) = > void =
2597
- transitionHook . memoizedState ;
2586
+ stateHook . queue . dispatch ;
2598
2587
setPending = dispatch ;
2599
2588
}
2600
2589
0 commit comments