(current, workInProgress, queue, instance, props, renderExpirationTime)
| 7992 | } |
| 7993 | |
| 7994 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 7995 | if (current !== null && current.updateQueue === queue) { |
| 7996 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 7997 | var currentQueue = queue; |
| 7998 | queue = workInProgress.updateQueue = { |
| 7999 | baseState: currentQueue.baseState, |
| 8000 | expirationTime: currentQueue.expirationTime, |
| 8001 | first: currentQueue.first, |
| 8002 | last: currentQueue.last, |
| 8003 | isInitialized: currentQueue.isInitialized, |
| 8004 | capturedValues: currentQueue.capturedValues, |
| 8005 | // These fields are no longer valid because they were already committed. |
| 8006 | // Reset them. |
| 8007 | callbackList: null, |
| 8008 | hasForceUpdate: false |
| 8009 | }; |
| 8010 | } |
| 8011 | |
| 8012 | { |
| 8013 | // Set this flag so we can warn if setState is called inside the update |
| 8014 | // function of another setState. |
| 8015 | queue.isProcessing = true; |
| 8016 | } |
| 8017 | |
| 8018 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 8019 | // increase this accordingly. |
| 8020 | queue.expirationTime = NoWork; |
| 8021 | |
| 8022 | // TODO: We don't know what the base state will be until we begin work. |
| 8023 | // It depends on which fiber is the next current. Initialize with an empty |
| 8024 | // base state, then set to the memoizedState when rendering. Not super |
| 8025 | // happy with this approach. |
| 8026 | var state = void 0; |
| 8027 | if (queue.isInitialized) { |
| 8028 | state = queue.baseState; |
| 8029 | } else { |
| 8030 | state = queue.baseState = workInProgress.memoizedState; |
| 8031 | queue.isInitialized = true; |
| 8032 | } |
| 8033 | var dontMutatePrevState = true; |
| 8034 | var update = queue.first; |
| 8035 | var didSkip = false; |
| 8036 | while (update !== null) { |
| 8037 | var updateExpirationTime = update.expirationTime; |
| 8038 | if (updateExpirationTime > renderExpirationTime) { |
| 8039 | // This update does not have sufficient priority. Skip it. |
| 8040 | var remainingExpirationTime = queue.expirationTime; |
| 8041 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 8042 | // Update the remaining expiration time. |
| 8043 | queue.expirationTime = updateExpirationTime; |
| 8044 | } |
| 8045 | if (!didSkip) { |
| 8046 | didSkip = true; |
| 8047 | queue.baseState = state; |
| 8048 | } |
| 8049 | // Continue to the next update. |
| 8050 | update = update.next; |
| 8051 | continue; |
no test coverage detected