@@ -152,7 +152,6 @@ import {
152
152
getRenderTargetTime ,
153
153
getWorkInProgressTransitions ,
154
154
shouldRemainOnPreviousScreen ,
155
- getWorkInProgressRootRenderLanes ,
156
155
} from './ReactFiberWorkLoop' ;
157
156
import {
158
157
OffscreenLane ,
@@ -161,7 +160,6 @@ import {
161
160
includesSomeLane ,
162
161
mergeLanes ,
163
162
claimNextRetryLane ,
164
- includesOnlyNonUrgentLanes ,
165
163
} from './ReactFiberLane' ;
166
164
import { resetChildFibers } from './ReactChildFiber' ;
167
165
import { createScopeInstance } from './ReactFiberScope' ;
@@ -534,41 +532,15 @@ function preloadInstanceAndSuspendIfNeeded(
534
532
// loaded yet.
535
533
workInProgress . flags |= MaySuspendCommit ;
536
534
537
- // Check if we're rendering at a "non-urgent" priority. This is the same
538
- // check that `useDeferredValue` does to determine whether it needs to
539
- // defer. This is partly for gradual adoption purposes (i.e. shouldn't start
540
- // suspending until you opt in with startTransition or Suspense) but it
541
- // also happens to be the desired behavior for the concrete use cases we've
542
- // thought of so far, like CSS loading, fonts, images, etc.
543
- //
544
- // We check the "root" render lanes here rather than the "subtree" render
545
- // because during a retry or offscreen prerender, the "subtree" render
546
- // lanes may include additional "base" lanes that were deferred during
547
- // a previous render.
548
- // TODO: We may decide to expose a way to force a fallback even during a
549
- // sync update.
550
- const rootRenderLanes = getWorkInProgressRootRenderLanes ( ) ;
551
- if ( ! includesOnlyNonUrgentLanes ( rootRenderLanes ) ) {
552
- // This is an urgent render. Don't suspend or show a fallback. Also,
553
- // there's no need to preload, because we're going to commit this
554
- // synchronously anyway.
555
- // TODO: Could there be benefit to preloading even during a synchronous
556
- // render? The main thread will be blocked until the commit phase, but
557
- // maybe the browser would be able to start loading off thread anyway?
558
- // Likely a micro-optimization either way because typically new content
559
- // is loaded during a transition, not an urgent render.
560
- } else {
561
- // Preload the instance
562
- const isReady = preloadInstance ( type , props ) ;
563
- if ( ! isReady ) {
564
- if ( shouldRemainOnPreviousScreen ( ) ) {
565
- // It's OK to suspend. Mark the fiber so we know to suspend before the
566
- // commit phase. Then continue rendering.
567
- workInProgress . flags |= ShouldSuspendCommit ;
568
- } else {
569
- // Trigger a fallback rather than block the render.
570
- suspendCommit ( ) ;
571
- }
535
+ // preload the instance if necessary. Even if this is an urgent render there
536
+ // could be benefits to preloading early.
537
+ // @TODO we should probably do the preload in begin work
538
+ const isReady = preloadInstance ( type , props ) ;
539
+ if ( ! isReady ) {
540
+ if ( shouldRemainOnPreviousScreen ( ) ) {
541
+ workInProgress . flags |= ShouldSuspendCommit ;
542
+ } else {
543
+ suspendCommit ( ) ;
572
544
}
573
545
}
574
546
}
@@ -588,17 +560,12 @@ function preloadResourceAndSuspendIfNeeded(
588
560
589
561
workInProgress . flags |= MaySuspendCommit ;
590
562
591
- const rootRenderLanes = getWorkInProgressRootRenderLanes ( ) ;
592
- if ( ! includesOnlyNonUrgentLanes ( rootRenderLanes ) ) {
593
- // This is an urgent render. Don't suspend or show a fallback.
594
- } else {
595
- const isReady = preloadResource ( resource ) ;
596
- if ( ! isReady ) {
597
- if ( shouldRemainOnPreviousScreen ( ) ) {
598
- workInProgress . flags |= ShouldSuspendCommit ;
599
- } else {
600
- suspendCommit ( ) ;
601
- }
563
+ const isReady = preloadResource ( resource ) ;
564
+ if ( ! isReady ) {
565
+ if ( shouldRemainOnPreviousScreen ( ) ) {
566
+ workInProgress . flags |= ShouldSuspendCommit ;
567
+ } else {
568
+ suspendCommit ( ) ;
602
569
}
603
570
}
604
571
}
0 commit comments