(current, workInProgress, queue, instance, props, renderExpirationTime)
| 7316 | } |
| 7317 | |
| 7318 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 7319 | if (current !== null && current.updateQueue === queue) { |
| 7320 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 7321 | var currentQueue = queue; |
| 7322 | queue = workInProgress.updateQueue = { |
| 7323 | baseState: currentQueue.baseState, |
| 7324 | expirationTime: currentQueue.expirationTime, |
| 7325 | first: currentQueue.first, |
| 7326 | last: currentQueue.last, |
| 7327 | isInitialized: currentQueue.isInitialized, |
| 7328 | capturedValues: currentQueue.capturedValues, |
| 7329 | // These fields are no longer valid because they were already committed. |
| 7330 | // Reset them. |
| 7331 | callbackList: null, |
| 7332 | hasForceUpdate: false |
| 7333 | }; |
| 7334 | } |
| 7335 | |
| 7336 | { |
| 7337 | // Set this flag so we can warn if setState is called inside the update |
| 7338 | // function of another setState. |
| 7339 | queue.isProcessing = true; |
| 7340 | } |
| 7341 | |
| 7342 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 7343 | // increase this accordingly. |
| 7344 | queue.expirationTime = NoWork; |
| 7345 | |
| 7346 | // TODO: We don't know what the base state will be until we begin work. |
| 7347 | // It depends on which fiber is the next current. Initialize with an empty |
| 7348 | // base state, then set to the memoizedState when rendering. Not super |
| 7349 | // happy with this approach. |
| 7350 | var state = void 0; |
| 7351 | if (queue.isInitialized) { |
| 7352 | state = queue.baseState; |
| 7353 | } else { |
| 7354 | state = queue.baseState = workInProgress.memoizedState; |
| 7355 | queue.isInitialized = true; |
| 7356 | } |
| 7357 | var dontMutatePrevState = true; |
| 7358 | var update = queue.first; |
| 7359 | var didSkip = false; |
| 7360 | while (update !== null) { |
| 7361 | var updateExpirationTime = update.expirationTime; |
| 7362 | if (updateExpirationTime > renderExpirationTime) { |
| 7363 | // This update does not have sufficient priority. Skip it. |
| 7364 | var remainingExpirationTime = queue.expirationTime; |
| 7365 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 7366 | // Update the remaining expiration time. |
| 7367 | queue.expirationTime = updateExpirationTime; |
| 7368 | } |
| 7369 | if (!didSkip) { |
| 7370 | didSkip = true; |
| 7371 | queue.baseState = state; |
| 7372 | } |
| 7373 | // Continue to the next update. |
| 7374 | update = update.next; |
| 7375 | continue; |
no test coverage detected