Skip to content

Commit 862287b

Browse files
committed
Refactor legacy update queue
Refactors legacy update queue to incoporate rebasing fix. Uses nearly the same approach as the hook update queue but has to handle a few other cases.
1 parent aaacbe9 commit 862287b

File tree

5 files changed

+290
-291
lines changed

5 files changed

+290
-291
lines changed

packages/react-noop-renderer/src/createReactNoop.js

+24-11
Original file line numberDiff line numberDiff line change
@@ -1142,20 +1142,33 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
11421142

11431143
function logUpdateQueue(updateQueue: UpdateQueue<mixed>, depth) {
11441144
log(' '.repeat(depth + 1) + 'QUEUED UPDATES');
1145-
const firstUpdate = updateQueue.firstUpdate;
1146-
if (!firstUpdate) {
1145+
const last = updateQueue.baseQueue;
1146+
if (last === null) {
11471147
return;
11481148
}
1149+
const first = last.next;
1150+
let update = first;
1151+
if (update !== null) {
1152+
do {
1153+
log(
1154+
' '.repeat(depth + 1) + '~',
1155+
'[' + update.expirationTime + ']',
1156+
);
1157+
} while (update !== null && update !== first);
1158+
}
11491159

1150-
log(
1151-
' '.repeat(depth + 1) + '~',
1152-
'[' + firstUpdate.expirationTime + ']',
1153-
);
1154-
while (firstUpdate.next) {
1155-
log(
1156-
' '.repeat(depth + 1) + '~',
1157-
'[' + firstUpdate.expirationTime + ']',
1158-
);
1160+
const lastPending = updateQueue.shared.pending;
1161+
if (lastPending !== null) {
1162+
const firstPending = lastPending.next;
1163+
let pendingUpdate = firstPending;
1164+
if (pendingUpdate !== null) {
1165+
do {
1166+
log(
1167+
' '.repeat(depth + 1) + '~',
1168+
'[' + pendingUpdate.expirationTime + ']',
1169+
);
1170+
} while (pendingUpdate !== null && pendingUpdate !== firstPending);
1171+
}
11591172
}
11601173
}
11611174

packages/react-reconciler/src/ReactFiberHooks.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -1299,11 +1299,7 @@ function dispatchAction<S, A>(
12991299
// This is the first update. Create a circular list.
13001300
update.next = update;
13011301
} else {
1302-
const first = pending.next;
1303-
if (first !== null) {
1304-
// Still circular.
1305-
update.next = first;
1306-
}
1302+
update.next = pending.next;
13071303
pending.next = update;
13081304
}
13091305
queue.pending = update;

packages/react-reconciler/src/ReactFiberWorkLoop.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,7 @@ export function checkForWrongSuspensePriorityInDEV(sourceFiber: Fiber) {
28582858
// has triggered any high priority updates
28592859
const updateQueue = current.updateQueue;
28602860
if (updateQueue !== null) {
2861-
let update = updateQueue.firstUpdate;
2861+
let update = updateQueue.baseQueue;
28622862
while (update !== null) {
28632863
const priorityLevel = update.priority;
28642864
if (

0 commit comments

Comments
 (0)