()
| 850 | } |
| 851 | |
| 852 | export function requestDeferredLane(): Lane { |
| 853 | if (workInProgressDeferredLane === NoLane) { |
| 854 | // If there are multiple useDeferredValue hooks in the same render, the |
| 855 | // tasks that they spawn should all be batched together, so they should all |
| 856 | // receive the same lane. |
| 857 | |
| 858 | // Check the priority of the current render to decide the priority of the |
| 859 | // deferred task. |
| 860 | |
| 861 | // OffscreenLane is used for prerendering, but we also use OffscreenLane |
| 862 | // for incremental hydration. It's given the lowest priority because the |
| 863 | // initial HTML is the same as the final UI. But useDeferredValue during |
| 864 | // hydration is an exception — we need to upgrade the UI to the final |
| 865 | // value. So if we're currently hydrating, we treat it like a transition. |
| 866 | const isPrerendering = |
| 867 | includesSomeLane(workInProgressRootRenderLanes, OffscreenLane) && |
| 868 | !getIsHydrating(); |
| 869 | if (isPrerendering) { |
| 870 | // There's only one OffscreenLane, so if it contains deferred work, we |
| 871 | // should just reschedule using the same lane. |
| 872 | workInProgressDeferredLane = OffscreenLane; |
| 873 | } else { |
| 874 | // Everything else is spawned as a transition. |
| 875 | workInProgressDeferredLane = claimNextTransitionDeferredLane(); |
| 876 | } |
| 877 | } |
| 878 | |
| 879 | // Mark the parent Suspense boundary so it knows to spawn the deferred lane. |
| 880 | const suspenseHandler = getSuspenseHandler(); |
| 881 | if (suspenseHandler !== null) { |
| 882 | // TODO: As an optimization, we shouldn't entangle the lanes at the root; we |
| 883 | // can entangle them using the baseLanes of the Suspense boundary instead. |
| 884 | // We only need to do something special if there's no Suspense boundary. |
| 885 | suspenseHandler.flags |= DidDefer; |
| 886 | } |
| 887 | |
| 888 | return workInProgressDeferredLane; |
| 889 | } |
| 890 | |
| 891 | export function scheduleViewTransitionEvent( |
| 892 | fiber: Fiber, |
no test coverage detected