(current, workInProgress, queue, instance, props, renderExpirationTime)
| 8085 | } |
| 8086 | |
| 8087 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 8088 | if (current !== null && current.updateQueue === queue) { |
| 8089 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 8090 | var currentQueue = queue; |
| 8091 | queue = workInProgress.updateQueue = { |
| 8092 | baseState: currentQueue.baseState, |
| 8093 | expirationTime: currentQueue.expirationTime, |
| 8094 | first: currentQueue.first, |
| 8095 | last: currentQueue.last, |
| 8096 | isInitialized: currentQueue.isInitialized, |
| 8097 | capturedValues: currentQueue.capturedValues, |
| 8098 | // These fields are no longer valid because they were already committed. |
| 8099 | // Reset them. |
| 8100 | callbackList: null, |
| 8101 | hasForceUpdate: false |
| 8102 | }; |
| 8103 | } |
| 8104 | |
| 8105 | { |
| 8106 | // Set this flag so we can warn if setState is called inside the update |
| 8107 | // function of another setState. |
| 8108 | queue.isProcessing = true; |
| 8109 | } |
| 8110 | |
| 8111 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 8112 | // increase this accordingly. |
| 8113 | queue.expirationTime = NoWork; |
| 8114 | |
| 8115 | // TODO: We don't know what the base state will be until we begin work. |
| 8116 | // It depends on which fiber is the next current. Initialize with an empty |
| 8117 | // base state, then set to the memoizedState when rendering. Not super |
| 8118 | // happy with this approach. |
| 8119 | var state = void 0; |
| 8120 | if (queue.isInitialized) { |
| 8121 | state = queue.baseState; |
| 8122 | } else { |
| 8123 | state = queue.baseState = workInProgress.memoizedState; |
| 8124 | queue.isInitialized = true; |
| 8125 | } |
| 8126 | var dontMutatePrevState = true; |
| 8127 | var update = queue.first; |
| 8128 | var didSkip = false; |
| 8129 | while (update !== null) { |
| 8130 | var updateExpirationTime = update.expirationTime; |
| 8131 | if (updateExpirationTime > renderExpirationTime) { |
| 8132 | // This update does not have sufficient priority. Skip it. |
| 8133 | var remainingExpirationTime = queue.expirationTime; |
| 8134 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 8135 | // Update the remaining expiration time. |
| 8136 | queue.expirationTime = updateExpirationTime; |
| 8137 | } |
| 8138 | if (!didSkip) { |
| 8139 | didSkip = true; |
| 8140 | queue.baseState = state; |
| 8141 | } |
| 8142 | // Continue to the next update. |
| 8143 | update = update.next; |
| 8144 | continue; |
no test coverage detected