Skip to content

Commit 99444a2

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 aeee2bf commit 99444a2

File tree

4 files changed

+289
-286
lines changed

4 files changed

+289
-286
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/ReactFiberWorkLoop.js

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

0 commit comments

Comments
 (0)