Skip to content

Commit

Permalink
Added more test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Vaughn committed May 16, 2019
1 parent fa0d5b1 commit 6d84e3c
Show file tree
Hide file tree
Showing 3 changed files with 396 additions and 79 deletions.
11 changes: 10 additions & 1 deletion packages/react-reconciler/src/ReactFiberScheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,12 @@ function commitRootImpl(root) {
// This usually means we've finished all the work, but it can also happen
// when something gets downprioritized during render, like a hidden tree.
root.lastPendingTime = firstPendingTimeBeforeCommit;

if (enableSchedulerTracing) {
if (firstPendingTimeBeforeCommit !== NoWork) {
restorePendingSchedulers(root, root.lastPendingTime);
}
}
}

if (root === workInProgressRoot) {
Expand Down Expand Up @@ -2183,7 +2189,6 @@ export function restorePendingSchedulers(
if (!enableUpdateSchedulerTracking) {
return;
}

const pendingSchedulersMap = root.pendingSchedulersMap;
let schedulers = pendingSchedulersMap.get(expirationTime);
if (schedulers == null) {
Expand Down Expand Up @@ -2322,6 +2327,10 @@ function startWorkOnPendingInteraction(root, expirationTime) {
}
});

// Store the current set of interactions on the FiberRoot for a few reasons:
// We can re-use it in hot functions like renderRoot() without having to
// recalculate it. This also provides DevTools with a way to access it when
// the onCommitRoot() hook is called.
root.memoizedSchedulers = memoizedSchedulers;
}

Expand Down
9 changes: 5 additions & 4 deletions packages/react-reconciler/src/ReactFiberUnwindWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ function throwException(
// Its effect list is no longer valid.
sourceFiber.firstEffect = sourceFiber.lastEffect = null;

if (enableUpdateSchedulerTracking) {
// If we have pending work still, restore the original schedulers
restorePendingSchedulers(root, renderExpirationTime);
}

if (
value !== null &&
typeof value === 'object' &&
Expand Down Expand Up @@ -331,10 +336,6 @@ function throwException(
if (enableSchedulerTracing) {
retry = Schedule_tracing_wrap(retry);
}
if (enableUpdateSchedulerTracking) {
// If we have pending work still, restore the original schedulers
restorePendingSchedulers(root, renderExpirationTime);
}
thenable.then(retry, retry);
}
workInProgress.effectTag |= ShouldCapture;
Expand Down
Loading

0 comments on commit 6d84e3c

Please sign in to comment.