@@ -27,7 +27,6 @@ export type PendingWork = {
2727 expirationTime : ExpirationTime ,
2828 isSuspended : boolean ,
2929 shouldTryResuming : boolean ,
30- isRenderPhaseWork : boolean ,
3130 next : PendingWork | null ,
3231} ;
3332
@@ -50,7 +49,8 @@ export function addPendingWork(
5049 let insertBefore = root . firstPendingWork ;
5150 while ( insertBefore !== null ) {
5251 if ( insertBefore . expirationTime >= expirationTime ) {
53- // Retry anything with an equal or lower expiration time
52+ // Retry anything with an equal or lower expiration time, since it may
53+ // be unblocked by the new work.
5454 insertBefore . shouldTryResuming = true ;
5555 }
5656 if ( insertBefore . expirationTime === expirationTime ) {
@@ -74,45 +74,11 @@ export function addPendingWork(
7474 expirationTime,
7575 isSuspended : false ,
7676 shouldTryResuming : false ,
77- isRenderPhaseWork : false ,
7877 next : null ,
7978 } ;
8079 insertPendingWorkAtPosition ( root , work , insertAfter , insertBefore ) ;
8180 }
8281}
83- export function addRenderPhasePendingWork (
84- root : FiberRoot ,
85- startTime : ExpirationTime ,
86- expirationTime : ExpirationTime ,
87- ) : void {
88- // Render-phase updates are treated differently because, while they
89- // could potentially unblock earlier pending work, we assume that they won't.
90- // They are also coalesced differently (see findNextExpirationTimeToWorkOn).
91- let insertAfter = null ;
92- let insertBefore = root . firstPendingWork ;
93- while ( insertBefore !== null ) {
94- if ( insertBefore . expirationTime === expirationTime ) {
95- // Found a matching bucket
96- return ;
97- }
98- if ( insertBefore . expirationTime > expirationTime ) {
99- // Found the insertion position
100- break ;
101- }
102- insertAfter = insertBefore ;
103- insertBefore = insertBefore . next ;
104- }
105- // No matching level found. Create a new one.
106- const work : PendingWork = {
107- startTime,
108- expirationTime,
109- isSuspended : false ,
110- shouldTryResuming : false ,
111- isRenderPhaseWork : true ,
112- next : null ,
113- } ;
114- insertPendingWorkAtPosition ( root , work , insertAfter , insertBefore ) ;
115- }
11682
11783export function flushPendingWork (
11884 root : FiberRoot ,
@@ -135,14 +101,14 @@ export function flushPendingWork(
135101 if ( firstUnflushedWork === null ) {
136102 if ( remainingExpirationTime !== NoWork ) {
137103 // There was an update during the render phase that wasn't flushed.
138- addRenderPhasePendingWork ( root , currentTime , remainingExpirationTime ) ;
104+ addPendingWork ( root , currentTime , remainingExpirationTime ) ;
139105 }
140106 } else if (
141107 remainingExpirationTime !== NoWork &&
142108 firstUnflushedWork . expirationTime > remainingExpirationTime
143109 ) {
144110 // There was an update during the render phase that wasn't flushed.
145- addRenderPhasePendingWork ( root , currentTime , remainingExpirationTime ) ;
111+ addPendingWork ( root , currentTime , remainingExpirationTime ) ;
146112 }
147113}
148114
@@ -168,7 +134,8 @@ export function resumePendingWork(
168134 root : FiberRoot ,
169135 expirationTime : ExpirationTime ,
170136) : void {
171- // Called when a promise resolves
137+ // Called when a promise resolves. This "pings" React to retry the previously
138+ // suspended render.
172139 let work = root . firstPendingWork ;
173140 while ( work !== null ) {
174141 if ( work . expirationTime === expirationTime ) {
@@ -184,19 +151,12 @@ export function resumePendingWork(
184151export function findNextExpirationTimeToWorkOn (
185152 root : FiberRoot ,
186153) : ExpirationTime {
187- // If there's a non-suspended interactive expiration time, return the first
188- // one. If everything is suspended, return the last retry time that's either
189- // a) a render phase update
190- // b) later or equal to the last suspended time
154+ // Return the earliest time that either isn't suspended or has been pinged.
191155 let lastSuspendedTime = NoWork ;
192- let lastRenderPhaseTime = NoWork ;
193156 let lastRetryTime = NoWork ;
194157 let work = root . firstPendingWork ;
195158 while ( work !== null ) {
196- if (
197- ! work . isSuspended &&
198- ( ! work . isRenderPhaseWork || lastSuspendedTime === NoWork )
199- ) {
159+ if ( ! work . isSuspended ) {
200160 return work . expirationTime ;
201161 }
202162 if (
@@ -209,13 +169,6 @@ export function findNextExpirationTimeToWorkOn(
209169 if ( lastRetryTime === NoWork || lastRetryTime < work . expirationTime ) {
210170 lastRetryTime = work . expirationTime ;
211171 }
212- if (
213- work . isRenderPhaseWork &&
214- ( lastRenderPhaseTime === NoWork ||
215- lastRenderPhaseTime < work . expirationTime )
216- ) {
217- lastRenderPhaseTime = work . expirationTime ;
218- }
219172 }
220173 work = work . next ;
221174 }
@@ -228,7 +181,7 @@ export function findNextExpirationTimeToWorkOn(
228181 if ( lastRetryTime >= lastSuspendedTime ) {
229182 return lastRetryTime ;
230183 }
231- return lastRenderPhaseTime ;
184+ return NoWork ;
232185}
233186
234187export function findStartTime ( root : FiberRoot , expirationTime : ExpirationTime ) {
0 commit comments