Skip to content

Commit

Permalink
Refactor legacy update queue
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
acdlite committed Dec 9, 2019
1 parent aaacbe9 commit 862287b
Show file tree
Hide file tree
Showing 5 changed files with 290 additions and 291 deletions.
35 changes: 24 additions & 11 deletions packages/react-noop-renderer/src/createReactNoop.js
Expand Up @@ -1142,20 +1142,33 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {

function logUpdateQueue(updateQueue: UpdateQueue<mixed>, depth) {
log(' '.repeat(depth + 1) + 'QUEUED UPDATES');
const firstUpdate = updateQueue.firstUpdate;
if (!firstUpdate) {
const last = updateQueue.baseQueue;
if (last === null) {
return;
}
const first = last.next;
let update = first;
if (update !== null) {
do {
log(
' '.repeat(depth + 1) + '~',
'[' + update.expirationTime + ']',
);
} while (update !== null && update !== first);
}

log(
' '.repeat(depth + 1) + '~',
'[' + firstUpdate.expirationTime + ']',
);
while (firstUpdate.next) {
log(
' '.repeat(depth + 1) + '~',
'[' + firstUpdate.expirationTime + ']',
);
const lastPending = updateQueue.shared.pending;
if (lastPending !== null) {
const firstPending = lastPending.next;
let pendingUpdate = firstPending;
if (pendingUpdate !== null) {
do {
log(
' '.repeat(depth + 1) + '~',
'[' + pendingUpdate.expirationTime + ']',
);
} while (pendingUpdate !== null && pendingUpdate !== firstPending);
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions packages/react-reconciler/src/ReactFiberHooks.js
Expand Up @@ -1299,11 +1299,7 @@ function dispatchAction<S, A>(
// This is the first update. Create a circular list.
update.next = update;
} else {
const first = pending.next;
if (first !== null) {
// Still circular.
update.next = first;
}
update.next = pending.next;
pending.next = update;
}
queue.pending = update;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-reconciler/src/ReactFiberWorkLoop.js
Expand Up @@ -2858,7 +2858,7 @@ export function checkForWrongSuspensePriorityInDEV(sourceFiber: Fiber) {
// has triggered any high priority updates
const updateQueue = current.updateQueue;
if (updateQueue !== null) {
let update = updateQueue.firstUpdate;
let update = updateQueue.baseQueue;
while (update !== null) {
const priorityLevel = update.priority;
if (
Expand Down

0 comments on commit 862287b

Please sign in to comment.