Skip to content

Commit

Permalink
Remove renderPhaseUpdates Map (#17625)
Browse files Browse the repository at this point in the history
* Remove renderPhaseUpdates Map

Follow up to #17484, which was reverted due to a bug found in www.

* Failing test: Dropped updates

When resetting render phase updates after a throw, we should only clear
the pending queue of hooks that were already processed.

* Fix non-render-phase updates being dropped

Detects if a queue has been processed by whether the hook was cloned.
If we change the implementation to an array instead of a list, we'll
need some other mechanism to determine whether the hook was processed.

* Regression test: startTransition in render phase

useTransition uses the state hook as part of its implementation, so we
need to fork it in the dispatcher used for re-renders, too.
  • Loading branch information
acdlite authored Jan 17, 2020
1 parent 29b4d07 commit 95bd7aa
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 147 deletions.
5 changes: 3 additions & 2 deletions packages/react-reconciler/src/ReactFiberBeginWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,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 @@ -1407,7 +1407,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
Loading

0 comments on commit 95bd7aa

Please sign in to comment.