163
markRootPinged,
164
markRootExpired,
165
markRootFinished,
166
- areLanesExpired,
166
getHighestPriorityLane,
167
addFiberToLanesMap,
168
movePendingFibersToMemoized,
839
// synchronously to block concurrent data mutations, and we'll includes
840
// all pending updates are included. If it still fails after the second
841
// attempt, we'll give up and commit the resulting tree.
843
- lanes = getLanesToRetrySynchronouslyOnError(root);
844
- if (lanes !== NoLanes) {
845
- exitStatus = renderRootSync(root, lanes);
842
+ const errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
843
+ if (errorRetryLanes !== NoLanes) {
844
+ lanes = errorRetryLanes;
845
+ exitStatus = renderRootSync(root, errorRetryLanes);
846
}
847
}
848
1007
1008
flushPassiveEffects();
1009
1010
- let lanes;
1011
- let exitStatus;
1012
- if (
1013
- root === workInProgressRoot &&
1014
- areLanesExpired(root, workInProgressRootRenderLanes)
1010
+ let lanes = getNextLanes(root, NoLanes);
1011
+ if (includesSomeLane(lanes, SyncLane)) {
1012
+ if (
1013
+ root === workInProgressRoot &&
1014
+ includesSomeLane(lanes, workInProgressRootRenderLanes)
1015
+ ) {
1016
+ // There's a partial tree, and at least one of its lanes has expired. Finish
1017
+ // rendering it before rendering the rest of the expired work.
1018
+ lanes = workInProgressRootRenderLanes;
1019
+ }
1020
+ } else if (
1021
+ !(
1022
+ enableSyncDefaultUpdates &&
1023
+ (includesSomeLane(lanes, DefaultLane) ||
1024
+ includesSomeLane(lanes, DefaultHydrationLane))
1025
+ )
1026
) {
1016
- // There's a partial tree, and at least one of its lanes has expired. Finish
1017
- // rendering it before rendering the rest of the expired work.
1018
- lanes = workInProgressRootRenderLanes;
1019
- exitStatus = renderRootSync(root, lanes);
1020
- } else {
1021
- lanes = getNextLanes(root, NoLanes);
1022
- exitStatus = renderRootSync(root, lanes);
1027
+ // There's no remaining sync work left.
1028
+ ensureRootIsScheduled(root, now());
1029
+ return null;
1030
}
1031
1032
+ let exitStatus = renderRootSync(root, lanes);
1033
if (root.tag !== LegacyRoot && exitStatus === RootErrored) {
1034
executionContext |= RetryAfterError;
1035
1047
// synchronously to block concurrent data mutations, and we'll includes
1048
// all pending updates are included. If it still fails after the second
1049
// attempt, we'll give up and commit the resulting tree.
1042
- lanes = getLanesToRetrySynchronouslyOnError(root);
1043
- if (lanes !== NoLanes) {
1050
+ const errorRetryLanes = getLanesToRetrySynchronouslyOnError(root);
1051
+ if (errorRetryLanes !== NoLanes) {
1052
+ lanes = errorRetryLanes;
1053
exitStatus = renderRootSync(root, lanes);
1054
}
1055
}
1067
const finishedWork: Fiber = (root.current.alternate: any);
1068
root.finishedWork = finishedWork;
1069
root.finishedLanes = lanes;
1061
- if (enableSyncDefaultUpdates && !includesSomeLane(lanes, SyncLane)) {
1070
+ if (
1071
+ enableSyncDefaultUpdates &&
1072
+ (includesSomeLane(lanes, DefaultLane) ||
1073
+ includesSomeLane(lanes, DefaultHydrationLane))
1074
+ ) {
1075
finishConcurrentRender(root, exitStatus, lanes);
1076
} else {
1077
commitRoot(root);
1839
}
1840
1841
return null;
1842
+ } else {
1843
+ if (__DEV__) {
1844
+ if (lanes === NoLanes) {
1845
+ console.error(
1846
+ 'root.finishedLanes should not be empty during a commit. This is a ' +
1847
+ 'bug in React.',
1848
+ );
1849
+ }
1850
+ }
1851
}
1852
root.finishedWork = null;
1853
root.finishedLanes = NoLanes;