(current, workInProgress, queue, instance, props, renderExpirationTime)
| 7225 | } |
| 7226 | |
| 7227 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 7228 | if (current !== null && current.updateQueue === queue) { |
| 7229 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 7230 | var currentQueue = queue; |
| 7231 | queue = workInProgress.updateQueue = { |
| 7232 | baseState: currentQueue.baseState, |
| 7233 | expirationTime: currentQueue.expirationTime, |
| 7234 | first: currentQueue.first, |
| 7235 | last: currentQueue.last, |
| 7236 | isInitialized: currentQueue.isInitialized, |
| 7237 | capturedValues: currentQueue.capturedValues, |
| 7238 | // These fields are no longer valid because they were already committed. |
| 7239 | // Reset them. |
| 7240 | callbackList: null, |
| 7241 | hasForceUpdate: false |
| 7242 | }; |
| 7243 | } |
| 7244 | |
| 7245 | { |
| 7246 | // Set this flag so we can warn if setState is called inside the update |
| 7247 | // function of another setState. |
| 7248 | queue.isProcessing = true; |
| 7249 | } |
| 7250 | |
| 7251 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 7252 | // increase this accordingly. |
| 7253 | queue.expirationTime = NoWork; |
| 7254 | |
| 7255 | // TODO: We don't know what the base state will be until we begin work. |
| 7256 | // It depends on which fiber is the next current. Initialize with an empty |
| 7257 | // base state, then set to the memoizedState when rendering. Not super |
| 7258 | // happy with this approach. |
| 7259 | var state = void 0; |
| 7260 | if (queue.isInitialized) { |
| 7261 | state = queue.baseState; |
| 7262 | } else { |
| 7263 | state = queue.baseState = workInProgress.memoizedState; |
| 7264 | queue.isInitialized = true; |
| 7265 | } |
| 7266 | var dontMutatePrevState = true; |
| 7267 | var update = queue.first; |
| 7268 | var didSkip = false; |
| 7269 | while (update !== null) { |
| 7270 | var updateExpirationTime = update.expirationTime; |
| 7271 | if (updateExpirationTime > renderExpirationTime) { |
| 7272 | // This update does not have sufficient priority. Skip it. |
| 7273 | var remainingExpirationTime = queue.expirationTime; |
| 7274 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 7275 | // Update the remaining expiration time. |
| 7276 | queue.expirationTime = updateExpirationTime; |
| 7277 | } |
| 7278 | if (!didSkip) { |
| 7279 | didSkip = true; |
| 7280 | queue.baseState = state; |
| 7281 | } |
| 7282 | // Continue to the next update. |
| 7283 | update = update.next; |
| 7284 | continue; |
no test coverage detected