@samitouri / QOS-React / commits / 8707755676

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.

Andrew Clark committed Oct 18, 2017 at 14:32 UTC 8707755676ddeb8d775ea5c2af0ce28b319733ce
1 file changed +6 -1
src/renderers/shared/fiber/ReactFiberUpdateQueue.js
+6 -1
@@ -198,7 +198,12 @@ function processUpdateQueue<State>(
198 // We need to create a work-in-progress queue, by cloning the current queue.
199 const currentQueue = queue;
200 queue = workInProgress.updateQueue = {
201 - baseState: currentQueue.baseState,
201 + // If we hit this clone path, the work-in-progress update queue is
202 + // conceptually empty. Which means its base state is the same as its
203 + // memoized state. This usually the same as the current queue's base
204 + // state, but could be different if setState was called during a child's
205 + // render phase.
206 + baseState: workInProgress.memoizedState,
207 expirationTime: currentQueue.expirationTime,
208 first: currentQueue.first,
209 last: currentQueue.last,