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