@@ -16,6 +16,7 @@ import type {
16
16
} from './SchedulerWithReactIntegration' ;
17
17
import type { Interaction } from 'scheduler/src/Tracing' ;
18
18
import type { SuspenseConfig } from './ReactFiberSuspenseConfig' ;
19
+ import type { SuspenseState } from './ReactFiberSuspenseComponent' ;
19
20
20
21
import {
21
22
warnAboutDeprecatedLifecycles ,
@@ -2183,18 +2184,23 @@ export function pingSuspendedRoot(
2183
2184
scheduleCallbackForRoot ( root , priorityLevel , suspendedTime ) ;
2184
2185
}
2185
2186
2186
- export function retryTimedOutBoundary ( boundaryFiber : Fiber ) {
2187
+ function retryTimedOutBoundary (
2188
+ boundaryFiber : Fiber ,
2189
+ retryTime : ExpirationTime ,
2190
+ ) {
2187
2191
// The boundary fiber (a Suspense component or SuspenseList component)
2188
2192
// previously was rendered in its fallback state. One of the promises that
2189
2193
// suspended it has resolved, which means at least part of the tree was
2190
2194
// likely unblocked. Try rendering again, at a new expiration time.
2191
2195
const currentTime = requestCurrentTime ( ) ;
2192
- const suspenseConfig = null ; // Retries don't carry over the already committed update.
2193
- const retryTime = computeExpirationForFiber (
2194
- currentTime ,
2195
- boundaryFiber ,
2196
- suspenseConfig ,
2197
- ) ;
2196
+ if ( retryTime === Never ) {
2197
+ const suspenseConfig = null ; // Retries don't carry over the already committed update.
2198
+ retryTime = computeExpirationForFiber (
2199
+ currentTime ,
2200
+ boundaryFiber ,
2201
+ suspenseConfig ,
2202
+ ) ;
2203
+ }
2198
2204
// TODO: Special case idle priority?
2199
2205
const priorityLevel = inferPriorityFromExpirationTime ( currentTime , retryTime ) ;
2200
2206
const root = markUpdateTimeFromFiberToRoot ( boundaryFiber , retryTime ) ;
@@ -2203,12 +2209,26 @@ export function retryTimedOutBoundary(boundaryFiber: Fiber) {
2203
2209
}
2204
2210
}
2205
2211
2212
+ export function retryDehydratedSuspenseBoundary ( boundaryFiber : Fiber ) {
2213
+ const suspenseState : null | SuspenseState = boundaryFiber . memoizedState ;
2214
+ let retryTime = Never ;
2215
+ if ( suspenseState !== null ) {
2216
+ retryTime = suspenseState . retryTime ;
2217
+ }
2218
+ retryTimedOutBoundary ( boundaryFiber , retryTime ) ;
2219
+ }
2220
+
2206
2221
export function resolveRetryThenable ( boundaryFiber : Fiber , thenable : Thenable ) {
2222
+ let retryTime = Never ; // Default
2207
2223
let retryCache : WeakSet < Thenable > | Set < Thenable > | null ;
2208
2224
if ( enableSuspenseServerRenderer ) {
2209
2225
switch ( boundaryFiber . tag ) {
2210
2226
case SuspenseComponent :
2211
2227
retryCache = boundaryFiber . stateNode ;
2228
+ const suspenseState : null | SuspenseState = boundaryFiber . memoizedState ;
2229
+ if ( suspenseState !== null ) {
2230
+ retryTime = suspenseState . retryTime ;
2231
+ }
2212
2232
break ;
2213
2233
default :
2214
2234
invariant (
@@ -2227,7 +2247,7 @@ export function resolveRetryThenable(boundaryFiber: Fiber, thenable: Thenable) {
2227
2247
retryCache . delete ( thenable ) ;
2228
2248
}
2229
2249
2230
- retryTimedOutBoundary ( boundaryFiber ) ;
2250
+ retryTimedOutBoundary ( boundaryFiber , retryTime ) ;
2231
2251
}
2232
2252
2233
2253
// Computes the next Just Noticeable Difference (JND) boundary.
0 commit comments