(current, workInProgress, queue, instance, props, renderExpirationTime)
| 8027 | } |
| 8028 | |
| 8029 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 8030 | if (current !== null && current.updateQueue === queue) { |
| 8031 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 8032 | var currentQueue = queue; |
| 8033 | queue = workInProgress.updateQueue = { |
| 8034 | baseState: currentQueue.baseState, |
| 8035 | expirationTime: currentQueue.expirationTime, |
| 8036 | first: currentQueue.first, |
| 8037 | last: currentQueue.last, |
| 8038 | isInitialized: currentQueue.isInitialized, |
| 8039 | capturedValues: currentQueue.capturedValues, |
| 8040 | // These fields are no longer valid because they were already committed. |
| 8041 | // Reset them. |
| 8042 | callbackList: null, |
| 8043 | hasForceUpdate: false |
| 8044 | }; |
| 8045 | } |
| 8046 | |
| 8047 | { |
| 8048 | // Set this flag so we can warn if setState is called inside the update |
| 8049 | // function of another setState. |
| 8050 | queue.isProcessing = true; |
| 8051 | } |
| 8052 | |
| 8053 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 8054 | // increase this accordingly. |
| 8055 | queue.expirationTime = NoWork; |
| 8056 | |
| 8057 | // TODO: We don't know what the base state will be until we begin work. |
| 8058 | // It depends on which fiber is the next current. Initialize with an empty |
| 8059 | // base state, then set to the memoizedState when rendering. Not super |
| 8060 | // happy with this approach. |
| 8061 | var state = void 0; |
| 8062 | if (queue.isInitialized) { |
| 8063 | state = queue.baseState; |
| 8064 | } else { |
| 8065 | state = queue.baseState = workInProgress.memoizedState; |
| 8066 | queue.isInitialized = true; |
| 8067 | } |
| 8068 | var dontMutatePrevState = true; |
| 8069 | var update = queue.first; |
| 8070 | var didSkip = false; |
| 8071 | while (update !== null) { |
| 8072 | var updateExpirationTime = update.expirationTime; |
| 8073 | if (updateExpirationTime > renderExpirationTime) { |
| 8074 | // This update does not have sufficient priority. Skip it. |
| 8075 | var remainingExpirationTime = queue.expirationTime; |
| 8076 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 8077 | // Update the remaining expiration time. |
| 8078 | queue.expirationTime = updateExpirationTime; |
| 8079 | } |
| 8080 | if (!didSkip) { |
| 8081 | didSkip = true; |
| 8082 | queue.baseState = state; |
| 8083 | } |
| 8084 | // Continue to the next update. |
| 8085 | update = update.next; |
| 8086 | continue; |
no test coverage detected