Render-phase setState bugfix (#11272)

Fixes a bug surfaced by www unit test.

I'm not yet sure the best way to test this; in the interest of landing
this fix quickly, I'll save the test for a follow-up.
This commit is contained in:
Andrew Clark
2017-10-18 14:32:31 -07:00
committed by GitHub
parent dee604dbe2
commit 8707755676
@@ -198,7 +198,12 @@ function processUpdateQueue<State>(
// We need to create a work-in-progress queue, by cloning the current queue.
const currentQueue = queue;
queue = workInProgress.updateQueue = {
baseState: currentQueue.baseState,
// If we hit this clone path, the work-in-progress update queue is
// conceptually empty. Which means its base state is the same as its
// memoized state. This usually the same as the current queue's base
// state, but could be different if setState was called during a child's
// render phase.
baseState: workInProgress.memoizedState,
expirationTime: currentQueue.expirationTime,
first: currentQueue.first,
last: currentQueue.last,