Skip to content

Commit

Permalink
Remove renderPhaseUpdates Map (#17484)
Browse files Browse the repository at this point in the history
* Render phase updates can now be extracted from the pending queue

* Use a custom dispatcher for the second render pass

* Discard render phase updates if component throws

When aborting a render, we also need to throw out render phase updates.
Remove the updates from the queues so they do not persist to the next
render. We already did a single pass through the whole list of hooks, so
we know that any pending updates must have been dispatched during the
render phase. The ones that were dispatched before we started rendering
were already transferred to the current hook's queue.
  • Loading branch information
sebmarkbage authored and acdlite committed Dec 14, 2019
1 parent be603f5 commit 8a347ed
Show file tree
Hide file tree
Showing 4 changed files with 444 additions and 133 deletions.
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Expand Up @@ -136,7 +136,7 @@ import {
calculateChangedBits,
scheduleWorkOnParentPath,
} from './ReactFiberNewContext';
import {resetHooks, renderWithHooks, bailoutHooks} from './ReactFiberHooks';
import {renderWithHooks, bailoutHooks} from './ReactFiberHooks';
import {stopProfilerTimerIfRunning} from './ReactProfilerTimer';
import {
getMaskedContext,
Expand Down Expand Up @@ -1319,7 +1319,8 @@ function mountIndeterminateComponent(
workInProgress.tag = ClassComponent;

// Throw out any hooks that were used.
resetHooks();
workInProgress.memoizedState = null;
workInProgress.updateQueue = null;

// Push context providers early to prevent context stack mismatches.
// During mounting we don't know the child context yet as the instance doesn't exist.
Expand Down

0 comments on commit 8a347ed

Please sign in to comment.