Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove LanePriority from getBumpedLaneForHydration #21086

Merged
merged 1 commit into from
Mar 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 29 additions & 25 deletions packages/react-reconciler/src/ReactFiberLane.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,43 +790,47 @@ export function getBumpedLaneForHydration(
root: FiberRoot,
renderLanes: Lanes,
): Lane {
getHighestPriorityLanes(renderLanes);
const highestLanePriority = return_highestLanePriority;
const renderLane = getHighestPriorityLane(renderLanes);

let lane;
switch (highestLanePriority) {
case SyncLanePriority:
lane = NoLane;
break;
case InputContinuousLanePriority:
switch (renderLane) {
case InputContinuousLane:
lane = InputContinuousHydrationLane;
break;
case DefaultHydrationLanePriority:
case DefaultLanePriority:
case DefaultLane:
lane = DefaultHydrationLane;
break;
case TransitionHydrationPriority:
case TransitionPriority:
lane = TransitionHydrationLane;
break;
case RetryLanePriority:
// Shouldn't be reachable under normal circumstances, so there's no
// dedicated lane for retry priority. Use the one for long transitions.
case TransitionLane1:
case TransitionLane2:
case TransitionLane3:
case TransitionLane4:
case TransitionLane5:
case TransitionLane6:
case TransitionLane7:
case TransitionLane8:
case TransitionLane9:
case TransitionLane10:
case TransitionLane11:
case TransitionLane12:
case TransitionLane13:
case TransitionLane14:
case TransitionLane15:
case TransitionLane16:
case RetryLane1:
case RetryLane2:
case RetryLane3:
case RetryLane4:
case RetryLane5:
lane = TransitionHydrationLane;
break;
case SelectiveHydrationLanePriority:
lane = SelectiveHydrationLane;
break;
case IdleHydrationLanePriority:
case IdleLanePriority:
case IdleLane:
lane = IdleHydrationLane;
break;
case OffscreenLanePriority:
case NoLanePriority:
default:
// Everything else is already either a hydration lane, or shouldn't
// be retried at a hydration lane.
lane = NoLane;
break;
default:
invariant(false, 'Invalid lane: %s. This is a bug in React.', lane);
}

// Check if the lane we chose is suspended. If so, that indicates that we
Expand Down
54 changes: 29 additions & 25 deletions packages/react-reconciler/src/ReactFiberLane.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -790,43 +790,47 @@ export function getBumpedLaneForHydration(
root: FiberRoot,
renderLanes: Lanes,
): Lane {
getHighestPriorityLanes(renderLanes);
const highestLanePriority = return_highestLanePriority;
const renderLane = getHighestPriorityLane(renderLanes);

let lane;
switch (highestLanePriority) {
case SyncLanePriority:
lane = NoLane;
break;
case InputContinuousLanePriority:
switch (renderLane) {
case InputContinuousLane:
lane = InputContinuousHydrationLane;
break;
case DefaultHydrationLanePriority:
case DefaultLanePriority:
case DefaultLane:
lane = DefaultHydrationLane;
break;
case TransitionHydrationPriority:
case TransitionPriority:
lane = TransitionHydrationLane;
break;
case RetryLanePriority:
// Shouldn't be reachable under normal circumstances, so there's no
// dedicated lane for retry priority. Use the one for long transitions.
case TransitionLane1:
case TransitionLane2:
case TransitionLane3:
case TransitionLane4:
case TransitionLane5:
case TransitionLane6:
case TransitionLane7:
case TransitionLane8:
case TransitionLane9:
case TransitionLane10:
case TransitionLane11:
case TransitionLane12:
case TransitionLane13:
case TransitionLane14:
case TransitionLane15:
case TransitionLane16:
case RetryLane1:
case RetryLane2:
case RetryLane3:
case RetryLane4:
case RetryLane5:
lane = TransitionHydrationLane;
break;
case SelectiveHydrationLanePriority:
lane = SelectiveHydrationLane;
break;
case IdleHydrationLanePriority:
case IdleLanePriority:
case IdleLane:
lane = IdleHydrationLane;
break;
case OffscreenLanePriority:
case NoLanePriority:
default:
// Everything else is already either a hydration lane, or shouldn't
// be retried at a hydration lane.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we forgot to add a case that we should have. You can have flow ensure that by ensuring there's a case for every lane, and then adding (type: empty); to the default case. Then, if we add a lane, this will fail flow checks and we'll remember to add the case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to do that but it didn't work in one case and it led to a bug and now I don't trust it

lane = NoLane;
break;
default:
invariant(false, 'Invalid lane: %s. This is a bug in React.', lane);
}

// Check if the lane we chose is suspended. If so, that indicates that we
Expand Down