Skip to content

Commit 8a347ed

Browse files
sebmarkbageacdlite
authored andcommitted
Remove renderPhaseUpdates Map (#17484)
* 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.
1 parent be603f5 commit 8a347ed

File tree

4 files changed

+444
-133
lines changed

4 files changed

+444
-133
lines changed

packages/react-reconciler/src/ReactFiberBeginWork.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ import {
136136
calculateChangedBits,
137137
scheduleWorkOnParentPath,
138138
} from './ReactFiberNewContext';
139-
import {resetHooks, renderWithHooks, bailoutHooks} from './ReactFiberHooks';
139+
import {renderWithHooks, bailoutHooks} from './ReactFiberHooks';
140140
import {stopProfilerTimerIfRunning} from './ReactProfilerTimer';
141141
import {
142142
getMaskedContext,
@@ -1319,7 +1319,8 @@ function mountIndeterminateComponent(
13191319
workInProgress.tag = ClassComponent;
13201320

13211321
// Throw out any hooks that were used.
1322-
resetHooks();
1322+
workInProgress.memoizedState = null;
1323+
workInProgress.updateQueue = null;
13231324

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

0 commit comments

Comments
 (0)