(current, workInProgress, queue, instance, props, renderExpirationTime)
| 7865 | } |
| 7866 | |
| 7867 | function processUpdateQueue(current, workInProgress, queue, instance, props, renderExpirationTime) { |
| 7868 | if (current !== null && current.updateQueue === queue) { |
| 7869 | // We need to create a work-in-progress queue, by cloning the current queue. |
| 7870 | var currentQueue = queue; |
| 7871 | queue = workInProgress.updateQueue = { |
| 7872 | baseState: currentQueue.baseState, |
| 7873 | expirationTime: currentQueue.expirationTime, |
| 7874 | first: currentQueue.first, |
| 7875 | last: currentQueue.last, |
| 7876 | isInitialized: currentQueue.isInitialized, |
| 7877 | capturedValues: currentQueue.capturedValues, |
| 7878 | // These fields are no longer valid because they were already committed. |
| 7879 | // Reset them. |
| 7880 | callbackList: null, |
| 7881 | hasForceUpdate: false |
| 7882 | }; |
| 7883 | } |
| 7884 | |
| 7885 | { |
| 7886 | // Set this flag so we can warn if setState is called inside the update |
| 7887 | // function of another setState. |
| 7888 | queue.isProcessing = true; |
| 7889 | } |
| 7890 | |
| 7891 | // Reset the remaining expiration time. If we skip over any updates, we'll |
| 7892 | // increase this accordingly. |
| 7893 | queue.expirationTime = NoWork; |
| 7894 | |
| 7895 | // TODO: We don't know what the base state will be until we begin work. |
| 7896 | // It depends on which fiber is the next current. Initialize with an empty |
| 7897 | // base state, then set to the memoizedState when rendering. Not super |
| 7898 | // happy with this approach. |
| 7899 | var state = void 0; |
| 7900 | if (queue.isInitialized) { |
| 7901 | state = queue.baseState; |
| 7902 | } else { |
| 7903 | state = queue.baseState = workInProgress.memoizedState; |
| 7904 | queue.isInitialized = true; |
| 7905 | } |
| 7906 | var dontMutatePrevState = true; |
| 7907 | var update = queue.first; |
| 7908 | var didSkip = false; |
| 7909 | while (update !== null) { |
| 7910 | var updateExpirationTime = update.expirationTime; |
| 7911 | if (updateExpirationTime > renderExpirationTime) { |
| 7912 | // This update does not have sufficient priority. Skip it. |
| 7913 | var remainingExpirationTime = queue.expirationTime; |
| 7914 | if (remainingExpirationTime === NoWork || remainingExpirationTime > updateExpirationTime) { |
| 7915 | // Update the remaining expiration time. |
| 7916 | queue.expirationTime = updateExpirationTime; |
| 7917 | } |
| 7918 | if (!didSkip) { |
| 7919 | didSkip = true; |
| 7920 | queue.baseState = state; |
| 7921 | } |
| 7922 | // Continue to the next update. |
| 7923 | update = update.next; |
| 7924 | continue; |
no test coverage detected